[DataGridPremium] Automatic parents and children selection
https://deploy-preview-13757--material-ui-x.netlify.app/x/react-data-grid/row-grouping/#automatic-parents-and-children-selection
Resolves #4248
- [x] Handle filtering behavior
- [x] Test coverage
- [x] Perf test
- [x] Extract https://github.com/mui/mui-x/pull/13757#discussion_r1700571749 out
- [ ] Allow to customize the clearing of unfiltered rows (
keepUnfilteredRowsSelected: boolean(default:false) similar to the existing propkeepNonExistentRowsSelected) Context: https://github.com/mui/mui-x/issues/14074#issuecomment-2268878622 - [ ] Add more tests (for filtering and
isRowSelectableuse cases)
Changelog
- Introduced a new prop
propagateRowSelectionfor client-side tree data and row grouping, when enabled:- Selecting/deselecting a parent row would select/deselect all the children rows.
- When all the child rows are selected, the parent row will be auto-selected.
- When a child row is deselected, if one or more parent rows are already selected, they will be deselected and moved to an indeterminate UI state.
- The Select All checkbox in the header row would select/deselect all the rows including child rows.
- Selecting a parent in an indeterminate state would select it and all its nested children.
- When filtering is applied, the previously selected rows that are now not a part of the filtered rows will be automatically deselected.
Follow up
Stuff that will follow after the PR merge:
- [ ] Make
propagateRowSelectiona default behavior in v8 - [ ] Improve nested selection performance (Context: https://github.com/mui/mui-x/pull/13757#discussion_r1679040751)
Deploy preview: https://deploy-preview-13757--material-ui-x.netlify.app/
Updated pages:
Generated by :no_entry_sign: dangerJS against 87f71d42e2a363a2d04ca769b90ec0355c8b8e9e
This pull request has conflicts, please resolve those before we can evaluate the pull request.
I see that the header row and parent rows are behaving differently when in indeterminate state. Header row deselects everything. I would expect it that it select everything (like the parent row)
https://github.com/user-attachments/assets/fe3483e4-79e3-4cca-a50d-a015a467d7e5
I see that the header row and parent rows are behaving differently when in indeterminate state. Header row deselects everything. I would expect it that it select everything (like the parent row)
@arminmeh GMail unselect when in this scenario I think at some point we were selecting all and we switch to the current behavior. I think both can make sense and it depends who you ask and the use case. Maybe being able to customize this behavior would be nice. And of course have the same behavior on both header and parent rows.
This pull request has conflicts, please resolve those before we can evaluate the pull request.
@MBilalShafi I'm using v5 this will be fixed there as well or only in V8 as you mention?
@MBilalShafi I'm using v5 this will be fixed there as well or only in V8 as you mention?
@arifannosh This is targeted for v7. The new features are not ported back to the previous versions, only critical bug fixes are ported. You could upgrade to v7 if you want to use this feature. Let me know if you need help with the migration.
Yes @MBilalShafi you can definitely help me in migration to v7. I had a lot of custom logic as well as there will be props and functions changes in mui v7. Can you list then over there.
@arifannosh We have the migration guides available for every major release upgrade. Some of the changes could even be automatically applied using codemods.
Here are the migration guides: v5 -> v6 migration: https://mui.com/x/migration/migration-data-grid-v5/ v6 -> v7 migration: https://mui.com/x/migration/migration-data-grid-v6/
I'd also suggest you to take any follow up discussion or any issues you face with the migration in a separate GitHub issue to keep this PR as relevant as possible. 🙏 Here's a guide on creating a new issue: https://mui.com/x/introduction/support/#github
This pull request has conflicts, please resolve those before we can evaluate the pull request.