Stable row identity
experimental
Refresh and reorder product objects while keeping stable selected row IDs.
Live example
Expected behavior
Stable IDs preserve selection and focus through refresh. Index fallback tracks positions. A duplicate leaves the prior rows intact.
Source
const api = createGrid({ rows, columns, getRowId: row => row.sku });
api.setSelection(['SKU-02']);
api.setRows(rows.map(row => ({ ...row })));
console.log(api.getRowById('SKU-02')?.data);const api = createGrid({ rows, columns, getRowId: row => row.sku });
api.setSelection(['SKU-02']);
api.setRows(rows.map(row => ({ ...row })));
console.log(api.getRowById('SKU-02')?.data);const api = createGrid({ rows, columns, getRowId: row => row.sku });
api.setSelection(['SKU-02']);
api.setRows(rows.map(row => ({ ...row })));
console.log(api.getRowById('SKU-02')?.data);const api = createGrid({ rows, columns, getRowId: row => row.sku });
api.setSelection(['SKU-02']);
api.setRows(rows.map(row => ({ ...row })));
console.log(api.getRowById('SKU-02')?.data);// JavaScript interop module
const api = createGrid({ rows, columns, getRowId: row => row.sku });
api.setSelection(['SKU-02']);
api.setRows(rows.map(row => ({ ...row })));
console.log(api.getRowById('SKU-02')?.data);API reference
| Kind | Name | Type | Description |
|---|---|---|---|
| Option | getRowId | — | Supplies a reusable logical ID, coerced to a string. |
| Method | getRowById | — | Looks up a row node by ID in constant time. |
| Method | getRowIndex | — | Returns the row’s source index or -1. |
| Error | DuplicateRowIdError | — | Rejects a duplicate without replacing the previous rows. |