-
-
Notifications
You must be signed in to change notification settings - Fork 1.6k
[DataGridPro] Retain expansion state on rows update #19697
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Deploy preview: https://deploy-preview-19697--material-ui-x.netlify.app/ Bundle size report
|
cherniavskii
approved these changes
Sep 29, 2025
This was referenced Sep 30, 2025
MBilalShafi
added a commit
to MBilalShafi/mui-x
that referenced
this pull request
Sep 30, 2025
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Labels
feature: Tree data
Related to the data grid Tree data feature
scope: data grid
Changes related to the data grid.
type: bug
It doesn't behave as expected.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Fixes #13064
Tree data example: https://stackblitz.com/edit/4ug6uohs
Row grouping example: https://stackblitz.com/edit/nqsdch2j
Main Fix
The
createRowTree()
pre processing passes down apreviousTree
param to the node generator methods,childrenExpanded
value is now reused from the previous tree if defined.It doesn't affect the functionality of
defaultGroupingExpansionDepth()
andisRowExpandedByDefault()
However if new rows are added with the same IDs as the previous ones, this logic will assume them the same rows and try to expand them, even though they are new ones. This shouldn't be a concern in a real use-case since IDs should be unique, but for numeric IDs always starting from 0, the users need to be mindful.
Additions
A couple API methods
expandAllRows()
andcollapseAllRows
are added to be used in case someone was using updation of therows
prop reference to reset the expansion status of the rows.As part of v9, I think we can make the
setRowChildrenExpansion()
to receive multiple rows rather than a single, or even a function that will be used by an internal traversal method.Changelog