Row selection
Pass withRowSelection to useDataGrid to add a checkbox column with a select-all checkbox
in the header. getRowId is required to provide stable row ids. Selected rows have the
data-selected attribute, use it to style a custom selection column:
Selected rows: []
Controlled selection
Pass rowSelection and onRowSelectionChange to useDataGrid to control selection state.
The state is keyed by row ids from getRowId:
Selected rows: 0
Single selection
Set enableMultiRowSelection: false to allow selecting one row at a time. Rows render a
radio control instead of a checkbox:
Selected row ID: none
Conditional selection
Pass a function to enableRowSelection to control which rows can be selected. Other rows
render a disabled checkbox:
Only active rows can be selected. Inactive rows show a disabled checkbox.
Select on row click
Set selectOnRowClick on DataGrid to select rows by clicking anywhere on a row:
- Click selects only that row
Shift + clickextends the selection to a range from the last selected rowCtrl / Cmd + clicktoggles the row without changing the othersSpacetoggles the focused row,Shift + Spaceextends the range
Bulk actions
Add DataGrid.SelectionBar next to DataGrid.Toolbar. While rows are selected, it replaces
the toolbar with the selected count, your bulk action controls and a clear button.
Get the selected rows with store.table.getSelectedRowModel().rows. See
Customization for the floating variant:
Row expansion
Pass withRowExpansion to useDataGrid to add an expand column. Set renderExpandedRow
prop on DataGrid to define the expanded content. Click the expand icon or press Enter on
a focused row to toggle it:
Set withTintedExpandedRows to paint the expanded row and its panel with the striped color:
Controlled expansion
Pass expanded and onExpandedChange to useDataGrid to control expansion state:
Expanded rows: 0
Expand all rows
Call store.table.toggleAllRowsExpanded() to expand or collapse all rows:
Conditional expansion
Use getRowCanExpand in useDataGrid to control which rows display the expand toggle:
Expand on click
Set expandOnRowClick on DataGrid to toggle row expansion by clicking anywhere on the row.
With tree data, expansion reveals child rows and renderExpandedRow is ignored:
Row numbers
Set withRowNumbers in useDataGrid to add a row number column.
Numbers count data rows only and continue across pages:
Row focus and keyboard navigation
Without cell selection, rows are the focus targets. The same keys work in the table body, the virtualized body and the list view:
Keys pressed inside controls within a row (checkboxes, buttons, editors) are not handled by the row. See Accessibility for the full list of keyboard interactions.
Row click and double-click
Use onRowClick and onRowDoubleClick props on DataGrid to respond to row interactions.
Both callbacks receive the row object and the event:
Cell selection
Pass withCellSelection to useDataGrid to enable spreadsheet-style cell range selection.
Cells become the focus targets instead of rows and text selection inside cells is disabled.
Set enableCellSelection: false on a column definition to exclude it from selection:
Use cellSelection and onCellSelectionChange to control the state. To read the current
selection, use store.getCellSelection() or the table helpers:
List view
Set listView on DataGrid to render rows as a list instead of a table, for example on narrow
screens. listView="cards" (default) renders bordered cards, listView="flat" renders items
divided by rules. Editing and row reorder are not available in list view:
By default, an item displays one label / value pair per visible data column. Use renderListItem
to render your own content inside the item:
With height set, the list scrolls inside a container of that height and pinned items stick
to its edges. Without height, pinned items are moved to the start / end of the list.
Row reorder
Pass withRowReorder to useDataGrid to add a drag handle column. onRowOrderChange is called
with a new copy of the data array after rows are reordered:
Reordering is pointer-only: the handle has no keyboard alternative. If keyboard users need to reorder rows, provide your own controls, for example move up/down actions in a row menu.
Sorting is disabled when withRowReorder is set. Row reorder is not available with tree data,
grouping, virtualize and list view. Pinned rows cannot be reordered, unpin a row to reorder it.