Cell Spanning
Preview

Merge adjacent DataGrid cells across columns or rows.

Overview

Cell spanning changes how cells are presented without changing the row model or source records.

SpanUse forConfigure with
ColumnsFull-width labels, summaries, or section rows.spanColumns
RowsRepeated values shared by adjacent displayed rows.spanRows

Spans work with every interaction mode. Column spans support row virtualization. Row spans require adjacent rows to be mounted together, so set rowVirtualization="never" on a known-small grid that uses spanRows. DataGrid reports a configuration error when row spanning and row virtualization are both active.

Examples

Rows and columns

Use resolver functions when the span depends on the current row. Row spanning merges adjacent displayed rows only; it does not sort or group the data.

Set spanRows: true to merge adjacent cells whose values are equal. A spanRows resolver can compare each candidate row with the run's anchor row. spanColumns counts visible columns from the current cell; use Infinity to span the rest of its current pinned region.

API Reference

Table options

OptionTypeDefaultDescription
enableCellSpanningbooleantrueEnables configured row and column spans.

Column options

OptionTypeDefaultDescription
enableCellSpanningbooleantrueAllows cells in the column to span rows or columns.
spanColumnsnumber | ((context) => number)1Sets how many visible columns the cell occupies. Values are limited to the current pinned region.
spanRowsboolean | ((context) => boolean)falseMerges adjacent displayed rows by equal value or a predicate.

Resolver context

OptionContextDescription
spanColumnsrow, column, tableResolve a column span from the current cell.
spanRowsanchorRow, anchorValue, previousRow, row, value, column, tableDecide whether the candidate row joins the current span.

On this page