const [expanded, setExpanded] = useState<ExpandedState>({});
const table = useGridTable({
data: treeData,
columns,
getSubRows: (row) => row.children,
getExpandedRowModel: getExpandedRowModel(),
state: { ..., expanded },
onExpandedChange: setExpanded,
});
const model = table.getExpandedRowModel();
// model.rows → flat array of visible rows (with depth, subRows, etc.)
// Per-row API:
// row.depth → nesting level (0 = root)
// row.subRows → child Row objects
// row.getCanExpand() → has children?
// row.getIsExpanded() → currently expanded?
// row.toggleExpanded() → toggle expand/collapse
// row.getLeafRows() → all leaf descendants