Documentation
Nested Tables
Nested tables allow each level of hierarchical data to have its own independent grid structure with completely different columns, enabling you to display different information at each nesting level.
Static Nested Tables (Pre-loaded Data)
This example demonstrates nested tables with all data pre-loaded. Expand companies to see their divisions with detailed metrics including revenue, profit margin, headcount, and location.
Dynamic Nested Tables (Lazy Loading)
This example shows lazy-loading nested tables where divisions are fetched on-demand when you expand company rows. The onRowGroupExpand handler manages dynamic data loading with built-in loading states.
What Are Nested Tables?
Nested tables extend the row grouping feature by allowing each level of your hierarchy to have its own independent table structure. While row grouping shows child rows with the same columns as the parent, nested tables let you define completely different columns for each level.
Key Difference: Row Grouping vs Nested Tables
- Row Grouping: All levels share the same column structure. Child rows display the same columns as parent rows.
- Nested Tables: Each level has its own independent column structure. Parent and child levels can have completely different columns.
Basic Setup
To enable nested tables, add the nestedTable property to your expandable column's HeaderObject. This property defines the column structure and configuration for the child table that appears when a row is expanded.
⚠️ Important
- You must still use the
rowGroupingprop to define the hierarchy (e.g.,rowGrouping={["divisions"]}) - The
expandableproperty must be set totrueon the column - Each level can have its own
nestedTableconfiguration for multi-level nesting
Nested Table Configuration
Understanding the Hierarchy
The demos above show a two-level nested table structure with completely different columns at each level:
Level 0: Companies (9 columns)
High-level company overview with industry, headquarters, market cap, CEO, revenue, and employee count.
Level 1: Divisions (6 columns)
Division-level details including division ID, division name, revenue, profit margin, headcount, and location.
💡 Multi-Level Support
These demos show two levels of nesting, but nested tables support unlimited nesting depth. You can create three, four, or more levels by adding nestedTable configurations at each level (e.g., Companies → Divisions → Teams → Members → Projects).
Data Structure
The data structure for nested tables is the same as row grouping - use nested arrays with property names matching your rowGrouping configuration:
const data = [
{
// Company level (Level 0)
companyName: "TechCorp Global",
industry: "Technology",
founded: 2015,
employees: 50000,
// ... other company fields
// Child divisions (Level 1)
divisions: [
{
divisionId: "DIV-001",
divisionName: "Cloud Services",
revenue: "$15B",
profitMargin: "35%",
headcount: 250,
location: "San Francisco, CA"
},
// ... more divisions
]
},
// ... more companies
];Inherited Props
For consistency and convenience, certain props are automatically inherited from the parent table and cannot be overridden in nested tables. This ensures a unified experience across all nesting levels.
📋 Props Inherited from Parent
These props are automatically inherited and should not be specified in the nestedTable config:
rows- Data is automatically provided from the parent row's nested arrayloadingStateRenderer,errorStateRenderer,emptyStateRenderer,tableEmptyStateRenderer- State renderers are shared across all levels- Icon props (
expandIcon,filterIcon,sortUpIcon,sortDownIcon, etc.) - Icons are consistent across all nesting levels
Dynamic Nested Tables
As shown in the dynamic demo above, nested tables support lazy-loading at each level using the onRowGroupExpand callback. You can specify different handlers for each nesting level, allowing you to fetch data on demand when users expand rows.
🚀 Benefits of Dynamic Loading
- Faster initial page load - only fetch top-level data
- Reduced memory usage - load child data only when needed
- Better performance with large hierarchical datasets
- Independent handlers for each nesting level
- Built-in loading, error, and empty state management
💡 Two Loading Patterns
- Static/Pre-loaded: All data is loaded upfront in the initial
rowsprop. Best for smaller datasets or when all data is readily available. See the first demo above. - Dynamic/Lazy-loaded: Child data is fetched on-demand when users expand rows using
onRowGroupExpandhandlers. Best for large datasets, API-driven data, or when initial load time matters. See the second demo above for implementation details.
Combining with Other Features
Nested tables are fully-featured SimpleTable instances, meaning they can receive most of the same props and configuration options as a regular table (except for inherited props). Each nested table can be configured independently with its own settings:
🎯 Full SimpleTable API Support
The nestedTable config accepts any SimpleTable prop, allowing complete customization at each nesting level.
Common configurations include:
- Row Selection: Enable
enableRowSelectionto allow selection at that nesting level - Column Resizing: Set
columnResizingto enable/disable resizing independently - Auto Expand Columns: Use
autoExpandColumnsto make columns fill available width - Sorting & Filtering: Configure
defaultSortConfig,enableColumnFiltering, and other sorting/filtering options per level - Themes: Apply different
themeorcustomThemesettings to each nested table (see Custom Theme) - Cell Renderers: Use custom
cellRenderer,valueFormatter, andheaderRendererfunctions with level-specific logic - Pagination: Enable
shouldPaginatewith custompageSizefor nested tables - Callbacks: Add
onCellClick,onCellChange, and other event handlers specific to that level - And more: Any prop from the API Reference can be used in the nested table configuration
See the demos above for complete implementation examples of both static and dynamic nested tables.
Related Features
- Row Grouping - Learn about the foundation of hierarchical data display
- Aggregate Functions - Calculate summaries for grouped data
- Programmatic Control - Control expansion and collapse programmatically