Skip to content
Niko Table

Niko Grid Core

DataGrid, DataGridCell, context, features, and dynamic columns provider.

The core pieces live in grid/core/. Put <DataGrid> inside DataTableRoot, wrapping DataTable.

Handles keyboard nav, the selection rectangle, drag-select, and scroll-into-view. Pass onRequestShortcuts to open the ? dialog.

import { DataGrid } from "@/components/niko-table/grid/core/data-grid"
<DataTableRoot data={grid.rows} columns={columns} getRowId={(r) => r.id}>
<DataGrid grid={grid} onRequestShortcuts={openShortcuts}>
<DataGridClipboard resolveCell={resolveCell} />
<DataTable>…</DataTable>
</DataGrid>
</DataTableRoot>
Name Type Description
grid UseDataGrid<TRow> From useDataGrid
children React.ReactNode Features + DataTable
className string Wrapper classes
onRequestShortcuts () => void Called on ? when focused (not editing)

Whole-row select, whole-column select, and fillSelectionWith live on the context, not on the headless hook. See useDataGridContext below.

Wrap each column cell. It finds the display index from the row id, after sort and filter. Do not pass TanStack row.index.

cell: (ctx) => (
<DataGridCell row={ctx.row.original} columnId="name">
{(p) => <GridTextCell {...p} resolve={(raw) => resolveCell("name", raw)} />}
</DataGridCell>
)
Prop Type Description
row TRow Row original (GridRow)
columnId string Editable column id
children (p) => ReactNode Render prop with cell APIs

Gives you the grid context. It throws outside <DataGrid>. Helpers include selectRow, selectColumn, fillSelectionWith, displayIndexOf, and the active selection bounds.

import { useDataGridContext } from "@/components/niko-table/grid/core/data-grid-context"
const { selectRow, fillSelectionWith } = useDataGridContext()

DataGridFeaturesProvider / useDataGridFeatures

Section titled “DataGridFeaturesProvider / useDataGridFeatures”

Opt-in children (clipboard, fill, move, reorder) register through useRegisterGridFeature. You rarely call this yourself. The feature components do.

Provides runtime column specs from useGridColumns. You need it for Dynamic Columns.

const cols = useGridColumns({ initialColumns })
<DataGridColumns value={cols}>
<DataGrid grid={grid}>…</DataGrid>
</DataGridColumns>
Hook / component Role
DataGridColumns Provides column API to descendants
useDataGridColumns Read and write column specs (throws if missing)