Documentation
Row Grouping
Row grouping allows you to organize your data into expandable hierarchical structures, making it easier to navigate large datasets with natural parent-child relationships.
Basic Setup
To enable row grouping, add the expandable: true property to your column header, structure your data with nested arrays, and specify the grouping hierarchy.
💡 Use Cases
- Organize teams by department and show individual members
- Display projects with their milestones and tasks
- Show product categories with subcategories and items
- Group transactions by account, invoice, and line items
🔑 Recommended: Use getRowId
When using row grouping with external sorting or dynamic data, it's highly recommended to provide the getRowId prop. This ensures stable row identification across data updates:
- Maintains correct expansion state when data is sorted or filtered
- Provides stable
rowIdPathin onRowGroupExpand - Prevents row group collapse when row order changes
- Essential for tables with external sorting enabled
Example: getRowId={({ row }) => row.id as string} or getRowId={({ row }) => row.uuid as string}
🎯 Need Different Columns at Each Level?
Row grouping shows child rows with the same columns as parent rows. If you need each level to have its own independent column structure (e.g., companies with 9 columns, divisions with 6 columns, teams with 19 columns), check out Nested Tables.
Row Grouping Configuration
Programmatic Control
Version 2.1.0 introduces powerful programmatic control over row grouping expansion. You can now control which hierarchy levels are expanded or collapsed using the table ref API. These methods give you fine-grained control over the visibility of nested data.
🎯 New Table API Methods (v2.1.0)
expandAll()- Expand all rows at all depthscollapseAll()- Collapse all rows at all depthsexpandDepth(depth)- Expand all rows at a specific depth (0-indexed)collapseDepth(depth)- Collapse all rows at a specific depth (0-indexed)toggleDepth(depth)- Toggle expansion for a specific depthsetExpandedDepths(depths)- Set which depths are expanded (replaces current state)getExpandedDepths()- Get currently expanded depths as a SetgetGroupingProperty(depth)- Get the grouping property name for a depth indexgetGroupingDepth(property)- Get the depth index for a grouping property name
Dynamic Row Loading
For large datasets, use the onRowGroupExpand callback to load nested data on-demand. This example demonstrates a three-level hierarchy (Regions → Stores → Products) where child rows are fetched from an API only when their parent is expanded. The callback provides powerful helper functions like setLoading, setError, and setEmpty for state management, plus rowIndexPath (v2.2.9+: contains only numeric indices) and rowIdPath (when getRowId is provided) for easy nested data updates.
💡 Benefits
- Faster initial load - only top-level rows are fetched
- Reduced memory usage - child data loaded as needed
- Better performance with large hierarchical datasets
- Seamless integration with server-side APIs
- Built-in state management with setLoading, setError, and setEmpty helpers
- Simple nested data updates using rowIndexPath array