Multi-level headers
Group related columns beneath a shared parent header.
For example, group product and quantity under Order details. The current preview has a single header; add the group to your app's column definitions.
View code
Sample data included in the code · 6 rows
Usage guide
#Use a shared heading for related columns such as delivery country, city, and address. Parent and individual headings appear across two or more rows.
Integration steps
- Choose columns to group
For example, group product and quantity under Order details. The current preview has a single header; add the group to your app's column definitions.
- Create a parent heading
Add a columnDefs entry with headerName set to Order details and place product and quantity columns in its children array.
- Inspect the expanded result
Pass the new columnDefs array to the Grid. Product and quantity appear beneath the parent heading, with sorting and resizing available on each column.
Multi-level headers make related columns easier to identify. Source row data does not need to change shape.
Distinguish a parent group's name from the columns that read actual data. The product column's field remains product.
Useful terms
- children
- The child columns contained within a parent header.
- groupId
- A unique name identifying a header group.
Key API examples
Application code that references the registered Grid element as grid.
grid.columnDefs = [{ headerName: 'Order', groupId: 'order', children: [
{field:'product', headerName:'Product'},
{field:'quantity', headerName:'Quantity'}
]}];API reference
#Events1
| Events | Detail type | Description |
|---|---|---|
{ groupId: string; open: boolean } | fires when a header group expands or collapses. |
Methods1
| Method / Arguments | Return type | Description |
|---|---|---|
| groupId: string, open: boolean | Promise<void> | expand/collapse a header group by id (`groupId` or its declaration path). No-ops when the state already matches. |
ColumnDef1
| ColumnDef | Type / Required | Description |
|---|---|---|
'open' | 'closed'Optional | visibility rule relative to the parent header group's open/closed state (AG `columnGroupShow`): `'open'` shows only while the group is expanded, `'closed'` only while collapsed, omitted always. Any child declaring this gives the group its expand/collapse toggle. |
Explore each feature
Learn when to use each feature and how to configure it. Each guide identifies live examples and features you connect in your app.