SetRows clears all current rows of the table and sets new rows from the specifying parameter. Each row is a map keyed by the colum id. The map value currently can be a string or any number type If a row column is not found it is ignored
(values []map[string]interface{})
| 361 | // The map value currently can be a string or any number type |
| 362 | // If a row column is not found it is ignored |
| 363 | func (t *Table) SetRows(values []map[string]interface{}) { |
| 364 | |
| 365 | // Add missing rows |
| 366 | if len(values) > len(t.rows) { |
| 367 | count := len(values) - len(t.rows) |
| 368 | for row := 0; row < count; row++ { |
| 369 | t.insertRow(len(t.rows), nil) |
| 370 | } |
| 371 | // Remove remaining rows |
| 372 | } else if len(values) < len(t.rows) { |
| 373 | for row := len(values); row < len(t.rows); row++ { |
| 374 | t.removeRow(row) |
| 375 | } |
| 376 | } |
| 377 | |
| 378 | // Set rows values |
| 379 | for row := 0; row < len(values); row++ { |
| 380 | t.setRow(row, values[row]) |
| 381 | } |
| 382 | t.firstRow = 0 |
| 383 | t.rowCursor = -1 |
| 384 | t.recalc() |
| 385 | } |
| 386 | |
| 387 | // SetRow sets the value of all the cells of the specified row from |
| 388 | // the specified map indexed by column id. |