P粉7225212042023-08-14 09:01:23
It looks like you are using the defaultGroupingExpansionDepth property to control the initial expansion state of the DataGrid, but it may not update dynamically as you expand or collapse rows. In order to make the button work in the current expanded/collapsed state, you can use the controlled state method to manage the expanded state:
<DataGridPro treeData apiRef={dataGridApi} groupingExpansionState={expandedState === EXPAND_ALL} onGroupingExpandedChange={(params) => setExpandedState(params.expanded ? EXPAND_ALL : COLLAPSE_ALL) } // ... />