Basic tree data
Pass getSubRows to useDataGrid to define how child rows are read from your data.
The tree is rendered in the first visible data column: rows are indented, a chevron toggles
rows that have children and guide lines connect the levels:
Tree lines
Set withTreeLines={false} to hide the guide lines:
Icons and custom labels
The tree cell renders the output of the column cell renderer, use it to add icons or any
other inline content:
Filtering through tree hierarchy
Set filterFromLeafRows to filter from leaf rows upward. When a leaf row matches
the filter, its parent rows are kept to preserve the tree structure:
Pagination with expanded rows
By default, expanded sub-rows count toward the page size. Set paginateExpandedRows: false
to count top-level rows only:
Server-side expansion
Load children in your data fetching logic when expanded changes, then pass the updated nested data to the grid.
Use getRowCanExpand to display an expand control before children are loaded.
In this example, useFolders is your application's data fetching hook:
Per-row expand control
Use getRowCanExpand to control which rows can be expanded:
Selection
With withRowSelection, selecting a parent row selects its children. Set
enableSubRowSelection: false to select the parent row only:
List view and row reorder
In list view, tree rows are rendered flat without indentation. Row reorder is not available with tree data.