MCPcopy
hub / github.com/g3n/engine / SetRows

Method SetRows

gui/table.go:363–385  ·  view source on GitHub ↗

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{})

Source from the content-addressed store, hash-verified

361// The map value currently can be a string or any number type
362// If a row column is not found it is ignored
363func (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.

Callers

nothing calls this directly

Calls 4

insertRowMethod · 0.95
removeRowMethod · 0.95
setRowMethod · 0.95
recalcMethod · 0.95

Tested by

no test coverage detected