Rows
Preview

Configure DataGrid grouping, hierarchy, expanded details, and row pinning.

Overview

Rows are flat records by default and need no row-specific configuration. Add these capabilities only when the data needs them:

CapabilityUse forConfigure with
GroupingGroup-by views and aggregated values.enableGrouping, aggregationFn
HierarchyRecords that contain child records.getSubRows
DetailsSupplemental content that is not another record.getRowCanExpand, renderExpandedContent

Grouping creates summary rows, while hierarchy keeps parent rows as real data records. Avoid combining dynamic grouping with hierarchical source data unless the product-specific composition has been tested.

Row pinning is opt-in. Add pin actions where they make sense for the product and use stable row IDs when pinning or expansion must survive data changes. Saved views include grouping order; expansion, selection, and pinning are not included. See Saved Views.

Examples

Grouping and aggregation

Enable grouping on relevant columns to add them to Group by, then use aggregationFn and aggregatedCell for summaries. This example activates group rows to expand them and selects leaf rows.

Custom group rows

Use renderGroupedRowContent when grouped rows need a full-width presentation. The renderer receives the grouped row and table; Cubitt retains the row structure and interaction behavior.

Hierarchical rows

Return child records from getSubRows and place a DataGrid.RowExpander in the identifying column.

Expanded details

Use getRowCanExpand and renderExpandedContent when expansion reveals supplemental content rather than child rows.

Row pinning

Enable row pinning and call row.pin() from consumer-defined actions.

API Reference

Table options

OptionTypeDefaultDescription
enableGroupingbooleantrueEnables grouping for eligible columns.
groupedColumnMode"reorder" | "remove" | false"reorder"Moves grouped columns to the start, removes them from display, or leaves them in place.
onGroupingChangeOnChangeFn<GroupingState>State updaterReceives grouping updates when the consumer controls the slice.
getRowId(row, index, parent?) => stringIndex-derivedReturns a stable ID for each row.
getSubRows(row, index) => readonly TData[] | undefined-Returns child records for a hierarchical row.
getRowCanExpand(row) => booleanRows with childrenOverrides whether a row can expand.
onExpandedChangeOnChangeFn<ExpandedState>State updaterReceives expansion updates when the consumer controls the slice.
enableRowPinningboolean | ((row) => boolean)falseEnables pinning for every row or rows that match a predicate.
keepPinnedRowsbooleantrueKeeps pinned rows rendered when filtering removes them from the centre row model.
onRowPinningChangeOnChangeFn<RowPinningState>State updaterReceives row-pinning updates when the consumer controls the slice.

Column options

OptionTypeDefaultDescription
enableGroupingbooleantrueAllows the column to appear in Group by.
getGroupingValue(record, index, row) => unknownColumn valueReturns the value used to group the column.
aggregationFnAggregationFnOption<DataGridFeatures, TData>"auto"Calculates the grouped value for the column.
aggregatedCell(context) => ReactNodeFormatted aggregateRenders the grouped value.

Row and column methods

APISignatureDescription
column.toggleGrouping() => voidAdds or removes the column from grouping.
column.getIsGrouped() => booleanReturns whether the column is currently grouped.
row.getIsGrouped() => booleanReturns whether the row is a synthetic group row.
row.getCanExpand() => booleanReturns whether the row can expand.
row.getIsExpanded() => booleanReturns whether the row is expanded.
row.toggleExpanded(expanded?: boolean) => voidToggles or sets the row's expanded state.
row.getCanPin() => booleanReturns whether the row can be pinned.
row.getIsPinned() => "top" | "bottom" | falseReturns the row's current pinned position.
row.pin(position: "top" | "bottom" | false, includeLeafRows?, includeParentRows?) => voidPins the row or returns it to the centre.

DataGrid.Viewport

PropTypeDefaultDescription
renderExpandedContent(context) => ReactNode-Renders supplemental content below an expanded row.
renderGroupedRowContent(context) => ReactNode-Replaces each synthetic grouped row's generated cells with one full-width row header.

DataGrid.RowExpander

DataGrid adds this automatically to grouped rows. Use it directly for hierarchical rows and expanded details.

PropTypeDefaultDescription
rowRow<DataGridFeatures, TData>-Row controlled by the expander. Required.
labelstring"Toggle {row.id}"Accessible label for the expansion button.
aria-controlsstring-ID controlled by the expansion button.
classNamestring-Additional layout classes for the wrapper.

DataGridExpandedContentContext

The renderExpandedContent viewport prop receives this context.

FieldTypeDescription
rowRow<DataGridFeatures, TData>Expanded row.
tableDataGridTable<TData>Table instance.

DataGridGroupedRowContentContext

The renderGroupedRowContent viewport prop receives this context. Read group identity from row.groupingColumnId and row.groupingValue; row.original belongs to a leaf record.

FieldTypeDescription
rowRow<DataGridFeatures, TData>Synthetic grouped row.
tableDataGridTable<TData>Table instance.

On this page