# TanStack compatibility
Package: @mantine/data-grid
Import: import { DataGridTanStackCompat } from '@mantine/data-grid';
Description: DataGrid TanStack Table v8 feature support matrix

## TanStack Table version

DataGrid is built on [TanStack Table v9](https://tanstack.com/table/latest). The v9 packages are
peer dependencies, so your application controls the exact version:

```bash
yarn add @tanstack/react-table @tanstack/match-sorter-utils
```

## Feature support

## Bound types

TanStack Table v9 types take the registered feature set as their first generic argument.
DataGrid exports aliases that are already bound to its feature set:

```tsx
import { DataGridColumnDef, DataGridFilterFn } from '@mantine/data-grid';

const columns: DataGridColumnDef<Person>[] = [{ accessorKey: 'name', header: 'Name' }];

const exactMatch: DataGridFilterFn = (row, columnId, filterValue) =>
  String(row.getValue(columnId)) === filterValue;
```

To build TanStack types by hand, use the `dataGridFeatures` value and the `DataGridFeatures` type.

## Features and row models

In v9, features and row models are registered explicitly instead of `getXRowModel` options.
DataGrid registers the full feature set and all row models on every table. Features you do not
use are bypassed with the `manual*` options.

## Editing feature

Inline editing is a TanStack Table feature, `editingFeature`, registered on every DataGrid table.
It adds the `editing` state with the `onEditingChange` option and the following APIs:

* Table: `startEditing`, `saveEditing`, `cancelEditing`, `setEditing`
* Row: `getCanEdit`, `getIsEditing`, `getIsSaving`, `startEditing`, `saveEditing`, `cancelEditing`
* Column: `getCanEdit`
* Cell: `getCanEdit`, `getIsEditing`, `getEditingValue`, `setEditingValue`, `getEditingError`

The types are added to `@tanstack/table-core` with module augmentation, so the package must be
resolvable from your project. `editingFeature` is exported for tables built by hand with `useTable`.

## Utility columns

The grid injects display columns for its own features, their ids are exported as
`UTILITY_COLUMN_IDS`:

Utility columns are regular TanStack columns included in `table.getAllColumns()`, header groups
and `columnOrder`. If your code iterates columns (a custom visibility menu, an export), skip
columns with `meta.utility`.

The store keeps utility columns first in `columnOrder` and `columnPinning.start`. If you control
these slices with `tableOptions.atoms`, include the utility column ids in the atom value yourself.

## Using tableOptions

Any TanStack Table option not exposed by `useDataGrid` can be passed through `tableOptions`:

```tsx
const store = useDataGrid({
  data,
  columns,
  tableOptions: {
    enableMultiSort: true,
    maxMultiSortColCount: 3,
    sortDescFirst: false,
    debugTable: process.env.NODE_ENV === 'development',
  },
});
```

## Accessing table state

TanStack Table v9 replaced `table.getState()` with a store. Read state from `table.store.state`, or
subscribe to a single slice with `table.atoms`:

```tsx
const store = useDataGrid({ data, columns });

store.table.store.state.sorting;
store.table.atoms.sorting.get();
```

Commonly used slices are also available on the DataGrid store directly, for example
`store.getSorting()` and `store.getPagination()`.

## Module format

TanStack Table v9 is published as ES modules only. Bundlers such as Vite, webpack and Next.js handle
this transparently. If you consume DataGrid from CommonJS with a raw `require()`, you need Node
22.12 or newer (or 20.19+), where `require()` of an ES module is supported.
