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] Sorting on grouped row sorts within groups, not globally #15922

Closed
eslachance opened this issue Dec 17, 2024 · 3 comments
Closed
Labels
component: data grid This is the name of the generic UI component, not the React module! feature: Row grouping Related to the data grid Row grouping feature feature: Sorting Related to the data grid Sorting feature support: commercial Support request from paid users support: premium standard Support request from a Premium standard plan user. https://mui.com/legal/technical-support-sla/

Comments

@eslachance
Copy link

eslachance commented Dec 17, 2024

The problem in depth

I am grouping data we receive by date and within each date, rows are displayed with the time only. However, when sorting this column, instead of sorting the whole data and showing the oldest date first, it instead sorts the times inside each day, which isn't what I'm expecting or desire.

I have actually seen sorting work with groups, however, it seems to only happen if the group is separate from an existing data row. I don't want to show the date twice, so this solution wouldn't work for me.

There is an entire example of this issue on stackblitz: https://stackblitz.com/edit/react-yxuyax?file=Demo.tsx

Your environment

`npx @mui/envinfo`
  System:
    OS: Windows 11 10.0.22631
  Binaries:
    Node: 20.17.0 - C:\Program Files\nodejs\node.EXE
    npm: 10.8.2 - C:\Program Files\nodejs\npm.CMD
  Browsers:
    Edge: Chromium (127.0.2651.74)

TS config

{
  "compilerOptions": {
    "target": "ES2022",
    "lib": ["ES2023"],
    "module": "ESNext",
    "skipLibCheck": true,

    /* Bundler mode */
    "moduleResolution": "bundler",
    "allowImportingTsExtensions": true,
    "isolatedModules": true,
    "moduleDetection": "force",
    "noEmit": true,

    /* Linting */
    "strict": false,
    "noUnusedLocals": true,
    "noUnusedParameters": true,
    "noFallthroughCasesInSwitch": true,
    "baseUrl": "",
    "paths": {
      "@components/*": ["src/common/components/*"],
      "@api/*": ["src/common/api/*"],
      "@services/*": ["src/common/services/*"],
      "@util/*": ["src/util/*"],
      "@rbac": ["constants.js"],
      "@assets/*": ["src/assets/*"],
    }
  },
  "include": ["vite.config.ts"]
}

Search keywords: grid, row grouping, sorting

Order ID: 100631

@eslachance eslachance added status: waiting for maintainer These issues haven't been looked at yet by a maintainer support: commercial Support request from paid users labels Dec 17, 2024
@github-actions github-actions bot added component: data grid This is the name of the generic UI component, not the React module! support: premium standard Support request from a Premium standard plan user. https://mui.com/legal/technical-support-sla/ labels Dec 17, 2024
@michelengelen michelengelen changed the title [question] Sorting on grouped row sorts within groups, not globally [data grid] Sorting on grouped row sorts within groups, not globally Dec 18, 2024
@michelengelen
Copy link
Member

Hey @eslachance ... adding mainGroupingCriteria: 'creationDate', to the groupingColDef fixes this. Is that a sufficient solution for you?

@michelengelen michelengelen added status: waiting for author Issue with insufficient information feature: Sorting Related to the data grid Sorting feature feature: Row grouping Related to the data grid Row grouping feature and removed status: waiting for maintainer These issues haven't been looked at yet by a maintainer labels Dec 18, 2024
@eslachance
Copy link
Author

Hey @eslachance ... adding mainGroupingCriteria: 'creationDate', to the groupingColDef fixes this. Is that a sufficient solution for you?

That indeed does the trick. I'm pretty sure I didn't see this option used in any of the examples in the docs where grouping worked, so I assume there's some odd mix of things I'm doing that might affect the default sorting? Either way... yes that does indeed solve the problem, thank you!

@github-actions github-actions bot added status: waiting for maintainer These issues haven't been looked at yet by a maintainer and removed status: waiting for author Issue with insufficient information status: waiting for maintainer These issues haven't been looked at yet by a maintainer labels Dec 18, 2024
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.

Note

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

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: Row grouping Related to the data grid Row grouping feature feature: Sorting Related to the data grid Sorting feature support: commercial Support request from paid users support: premium standard Support request from a Premium standard plan user. https://mui.com/legal/technical-support-sla/
Projects
None yet
Development

No branches or pull requests

2 participants