Skip to content

DG005: Selector must match exactly one table ​

Thrown error
text
[datagrids DG005] `{name}` needs a selector that matches exactly one <table>; matched {count}.

This is a wiring mistake: the grid throws an Error with this message instead of half-working.

When it happens ​

new Datagrid(selector) or grid.remount(selector) got a CSS selector that matched no element, more than one element, or a single element that is not a <table> (reported as "matched 0"). Thrown synchronously by the constructor.

How to fix it ​

Use a unique selector ("#agents") or pass the HTMLTableElement itself, and create the grid after the table is in the document (for example after a tab or modal has rendered its content). Datagrid.get() and get() never throw; they return null.

Released under the MIT License.