---
url: https://akinozgen.github.io/datagrids/errors/DG005.md
description: >-
  One datagrids warning or error code — the message, when it happens and how to
  fix it.
---

# DG005: Selector must match exactly one table

```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`.

## Related

* [All warning codes](/errors/)
* [Grid options](/reference/options)
* [Static API & configure()](/reference/static)
