Skip to main content

Usage

<DataTable> is the one component you render. Every feature is opt-in through props, so the smallest useful grid is just columns + data:

import { DataTable } from '@ackplus/mui-tanstack-data-grid';

const columns = [
{ id: 'name', header: 'Name', accessorKey: 'name' },
{ id: 'email', header: 'Email', accessorKey: 'email' },
];

<DataTable columns={columns} data={rows} />;
Loading demo…

Anatomy​

The grid renders as a self-framing card with up to four regions, each a themeable, replaceable slot:

RegionAppears whenSlot
Toolbarany toolbar control is enabledtoolbar — see Toolbar
Headeralwaysheader / headerCell
Body (rows/cells)alwaysrow / cell, or renderListItem in list view
FooterenablePagination or footerFilterfooter / pagination

Prop groups​

Props fall into a few consistent naming conventions — learn the pattern, not 100 names:

ConventionMeaningExamples
enableXTurn a feature onenableSorting, enablePagination, enableColumnPinning
xModeClient vs server for a featurefilterMode, sortingMode, paginationMode
onXChangeState-change callback (Events)onSortingChange, onSelectionChange
renderXCustom render functionrenderDetailPanel, renderBulkActions, renderListItem
adjectivesVisual modifiersstriped, hover, fitToScreen

The full list with types, defaults, and possible values is in the Props reference.

Controlling the grid​

Two ways to drive the grid, use either or both:

  1. Declarative — pass initialState for a starting point, or controlled props (sorting + onSortingChange, …) to own the state.
  2. Imperative — pass apiRef and call methods like apiRef.current.export.exportCSV() or apiRef.current.selection.selectAll(). See the apiRef reference.
const apiRef = useRef<DataTableApi<User>>(null);

<>
<Button onClick={() => apiRef.current?.export.exportCSV()}>Export</Button>
<DataTable apiRef={apiRef} columns={columns} data={rows} enableExport />
</>;

TypeScript​

DataTable is generic over your row type — pass it for typed columns, callbacks, and apiRef:

<DataTable<User> columns={columns} data={users} />

Where to next​