Skip to content
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

[data grid] Nested grouping and sort by aggregation does not sort the second level #12684

Closed
mdoverhag opened this issue Apr 5, 2024 · 6 comments
Labels
component: data grid This is the name of the generic UI component, not the React module! feature: Aggregation Related to the data grid Aggregation feature feature: Row grouping Related to the data grid Row grouping feature feature: Sorting Related to the data grid Sorting feature status: expected behavior Does not imply the behavior is intended. Just that we know about it and can't work around it

Comments

@mdoverhag
Copy link

mdoverhag commented Apr 5, 2024

Steps to reproduce

Link to live example: https://stackblitz.com/edit/github-zzppol?file=src%2Fdemo.tsx

Steps:

  1. Group by Commodity
  2. Group by Trader name
  3. Add size aggregation to Trader name
  4. Sort by Group ascending
  5. Expand the row Corn
  6. Do secondary Sort by Trader name descending (CMD-click)

Current behavior

Trader names under Corn are not sorted by the aggregation.

Expected behavior

Trader names under Corn gets sorted by number of orders (Most at the top)

Context

We're grouping by Year-Month (have a separate string column for that). Then we group by sales person. We'd like to order the expanded Year-Month by the sales person with the most sales at the top.

Your environment

npx @mui/envinfo
  System:
    OS: macOS 14.4.1
  Binaries:
    Node: 20.11.1 - ~/.asdf/installs/nodejs/20.11.1/bin/node
    npm: 10.2.4 - ~/.asdf/plugins/nodejs/shims/npm
    pnpm: Not Found
  Browsers:
    Chrome: 123.0.6312.107
    Edge: Not Found
    Safari: 17.4.1
  npmPackages:
    @emotion/react: ^11.11.4 => 11.11.4
    @emotion/styled: ^11.11.5 => 11.11.5
    @mui/base:  5.0.0-beta.41
    @mui/core-downloads-tracker:  5.15.15
    @mui/icons-material: ^5.15.15 => 5.15.15
    @mui/material: ^5.15.15 => 5.15.15
    @mui/private-theming:  5.15.14
    @mui/styled-engine:  5.15.14
    @mui/system:  5.15.15
    @mui/types:  7.2.14
    @mui/utils:  5.15.14
    @mui/x-data-grid:  7.1.0
    @mui/x-data-grid-premium: ^7.1.0 => 7.1.0
    @mui/x-data-grid-pro:  7.1.0
    @mui/x-date-pickers:  7.1.0
    @mui/x-date-pickers-pro: ^7.1.0 => 7.1.0
    @mui/x-license:  7.0.0
    @types/react: ^18.2.66 => 18.2.72
    react: ^18.2.0 => 18.2.0
    react-dom: ^18.2.0 => 18.2.0
    typescript: ^5.4.2 => 5.4.3

Search keywords: group sort
Order ID: 37c0051b8b2fa563b59fcf5f2406f346Tz04Njg1OSxFPTE3NDI1NjE3ODcwMDAsUz1wcmVtaXVtLExNPXN1YnNjcmlwdGlvbixLVj0y

@mdoverhag mdoverhag added the status: waiting for maintainer These issues haven't been looked at yet by a maintainer label Apr 5, 2024
@mdoverhag mdoverhag changed the title Nested grouping and sort does not work since version 7.0.0 Nested groupin and sort by aggregation does not sort the second level Apr 5, 2024
@mdoverhag mdoverhag changed the title Nested groupin and sort by aggregation does not sort the second level Nested grouping and sort by aggregation does not sort the second level Apr 5, 2024
@mdoverhag
Copy link
Author

mdoverhag commented Apr 5, 2024

Hi, first bug report here. Thanks for a cool product.

We just recently started using X Data Grid Premium and I was going to try and update from version 6.19.8 to 7.1.0.

In 6.19.8 I seem to be able to get above to work as expected. But the sorting does no longer seem to work correctly in 7.0.0 or later.

@michelengelen
Copy link
Member

michelengelen commented Apr 5, 2024

Hey @mdoverhag and thanks for raising an issue here.
I am glad you like the product! ✨

The use case you have there is pretty advanced.
I just tried it and you are right. The second sorting does not work.

This clearly is a regression, so I will add this to our board

v6: https://stackblitz.com/edit/github-zzppol-p1ndqj

Screen.Recording.2024-04-05.at.10.55.09.mov

v7: https://stackblitz.com/edit/github-zzppol-vhewiz

Screen.Recording.2024-04-05.at.10.52.58.mov

@michelengelen michelengelen added component: data grid This is the name of the generic UI component, not the React module! regression A bug, but worse feature: Sorting Related to the data grid Sorting feature feature: Row grouping Related to the data grid Row grouping feature feature: Aggregation Related to the data grid Aggregation feature and removed status: waiting for maintainer These issues haven't been looked at yet by a maintainer labels Apr 5, 2024
@michelengelen michelengelen changed the title Nested grouping and sort by aggregation does not sort the second level [data grid] Nested grouping and sort by aggregation does not sort the second level Apr 5, 2024
@mdoverhag
Copy link
Author

Thanks for the prompt reply @michelengelen 👍 I'll keep a look out here then!

@cherniavskii cherniavskii self-assigned this Apr 9, 2024
@cherniavskii
Copy link
Member

Hi @mdoverhag
I checked both v6 and v7 (added links to demos in #12684 (comment)) and it seems to me that the behavior in v7 is correct.
In v6, sorting on the grouping column was only applied to the first level of the rows:

v6 v7

This was fixed #9679

We're grouping by Year-Month (have a separate string column for that). Then we group by sales person. We'd like to order the expanded Year-Month by the sales person with the most sales at the top.

Did you consider using multiple grouping columns for your use case?
Here's a working demo with Data Grid v7 https://stackblitz.com/edit/github-zzppol-u2w6mf

@cherniavskii cherniavskii added status: waiting for author Issue with insufficient information status: expected behavior Does not imply the behavior is intended. Just that we know about it and can't work around it and removed regression A bug, but worse labels Apr 11, 2024
@mdoverhag
Copy link
Author

Hi @cherniavskii,

Thank you for making the videos comparing v6 and v7. I get it, considering we're sorting on Grouping, the second level is also technically part of that column and it should be sorted alphabetically. 👍

Thanks for the suggestion on multiple grouping. We'll give that ago!

Copy link

⚠️ This issue has been closed. If you have a similar problem but not exactly the same, please open a new issue.
Now, if you have additional information related to this issue or things that could help future readers, feel free to leave a comment.

@mdoverhag: How did we do? Your experience with our support team matters to us. If you have a moment, please share your thoughts in this short Support Satisfaction survey.

@github-actions github-actions bot removed the status: waiting for author Issue with insufficient information label Apr 13, 2024
@cherniavskii cherniavskii removed their assignment Jun 11, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
component: data grid This is the name of the generic UI component, not the React module! feature: Aggregation Related to the data grid Aggregation feature feature: Row grouping Related to the data grid Row grouping feature feature: Sorting Related to the data grid Sorting feature status: expected behavior Does not imply the behavior is intended. Just that we know about it and can't work around it
Projects
None yet
Development

No branches or pull requests

3 participants