mui-x icon indicating copy to clipboard operation
mui-x copied to clipboard

[DataGridPremium] Automatic parents and children selection

Open MBilalShafi opened this issue 1 year ago • 5 comments

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 prop keepNonExistentRowsSelected) Context: https://github.com/mui/mui-x/issues/14074#issuecomment-2268878622
  • [ ] Add more tests (for filtering and isRowSelectable use cases)

Changelog

  • Introduced a new prop propagateRowSelection for client-side tree data and row grouping, when enabled:
    1. Selecting/deselecting a parent row would select/deselect all the children rows.
    2. When all the child rows are selected, the parent row will be auto-selected.
    3. 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.
    4. The Select All checkbox in the header row would select/deselect all the rows including child rows.
    5. Selecting a parent in an indeterminate state would select it and all its nested children.
    6. 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 propagateRowSelection a default behavior in v8
  • [ ] Improve nested selection performance (Context: https://github.com/mui/mui-x/pull/13757#discussion_r1679040751)

MBilalShafi avatar Jul 08 '24 07:07 MBilalShafi

Deploy preview: https://deploy-preview-13757--material-ui-x.netlify.app/

Updated pages:

Generated by :no_entry_sign: dangerJS against 87f71d42e2a363a2d04ca769b90ec0355c8b8e9e

mui-bot avatar Jul 08 '24 07:07 mui-bot

This pull request has conflicts, please resolve those before we can evaluate the pull request.

github-actions[bot] avatar Jul 10 '24 17:07 github-actions[bot]

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

arminmeh avatar Jul 22 '24 13:07 arminmeh

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.

flaviendelangle avatar Aug 01 '24 15:08 flaviendelangle

This pull request has conflicts, please resolve those before we can evaluate the pull request.

github-actions[bot] avatar Aug 13 '24 12:08 github-actions[bot]

@MBilalShafi I'm using v5 this will be fixed there as well or only in V8 as you mention?

arifannosh avatar Sep 18 '24 11:09 arifannosh

@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.

MBilalShafi avatar Sep 18 '24 19:09 MBilalShafi

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 avatar Sep 18 '24 21:09 arifannosh

@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

MBilalShafi avatar Sep 19 '24 05:09 MBilalShafi

This pull request has conflicts, please resolve those before we can evaluate the pull request.

github-actions[bot] avatar Sep 28 '24 06:09 github-actions[bot]