Skip to content

DG003: Rows have no key ​

Console warning
text
[datagrids DG003] No row key found (rowKey/id/DT_RowId); falling back to index. Selection and focus keeping are disabled.

Printed with console.warn, once per distinct message. configure({ warnings: false }) silences it.

When it happens ​

A row has no key: rowKey is not set and the row has neither id nor DT_RowId, or the rowKey path or function returned null or "". The grid falls back to the row's position (__i0, __i1, …).

How to fix it ​

Tell the grid which field identifies a row:

js
new Datagrid("#agents", { label: "Agents", rowKey: "uuid", columns });
new Datagrid("#stock", { label: "Stock", rowKey: (row) => `${row.unit}-${row.ref}`, columns });

Position keys change whenever the data changes, so selection, refreshRow(key), removeRow(key), row actions and focus restoration cannot follow a row across pages or reloads.

Released under the MIT License.