Skip to content

rows

The rows, when your application has them all in the browser — an array, or anything iterable.

TypeIterable<T>
Default[]
Live update (update())Yes
Angularthe [rows] input
<dz-grid>the rows property
Declared inpackages/dom/src/settings.ts

Any iterable of your objects: an array, a Set, a generator. The grid reads each value through the columns and identifies each row with getRowId; it never changes your objects. Sorting, filtering, the search and the pages then run in the browser.

To change the rows, give a new array with update({ rows }), never the same one changed: the rows are matched by their id, so the ones still there keep their focus, their selection and their open state, and a value that changed can flash. For a few rows at a time, a transaction is cheaper: grid.kernel.rows.applyTransaction({ add, patch, remove }). With sameRow, a reload keeps the old object of a row that did not really change.

A row whose id is missing or repeats is left out and told (invalid-row-id, duplicate-row-id). Rows that live on a server come through source instead.

import { createGrid } from '@dzgrid/dom';
import { EN } from '@dzgrid/dom/locales/en';
type Bird = { id: string; name: string; seen: number };
let birds: Bird[] = [{ id: 'b1', name: 'Robin', seen: 3 }];
const grid = createGrid<Bird>(document.getElementById('birds')!, {
rows: birds,
columns: [{ id: 'name', header: 'Bird' }, { id: 'seen', header: 'Seen', type: 'number' }],
getRowId: (b) => b.id,
messages: EN,
});
birds = [...birds, { id: 'b2', name: 'Wren', seen: 1 }];
grid.update({ rows: birds });