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] When using Datagrid's aggregation is it possible to somehow use group row's value instead of the aggregated one? #13027

Open
gulicJan opened this issue May 6, 2024 · 9 comments
Labels
component: data grid This is the name of the generic UI component, not the React module! customization: extend Logic customizability feature: Aggregation Related to the data grid Aggregation 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

@gulicJan
Copy link

gulicJan commented May 6, 2024

The problem in depth

image

Hey,

is there any way how to avoid the mentioned logic? I'm using aggregation and in some cases I want the group row to skip aggregation and use it's value instead (aggregation was done on the server for some specific cases).

MUI Example:

https://stackblitz.com/run?file=Demo.tsx

How to achieve that the Public grouped row's value 1Kb would be considered as the row's value instead of the aggregated value of 40 Kb.

image

Your environment

`npx @mui/envinfo`
  Chrome Version 124.0.6367.119
  System:
    OS: macOS 14.4.1
  Binaries:
    Node: 18.14.2 - ~/.nvm/versions/node/v18.14.2/bin/node
    Yarn: 1.22.19 - /usr/local/bin/yarn
    npm: 9.5.0 - ~/.nvm/versions/node/v18.14.2/bin/npm
  Browsers:
    Chrome: 124.0.6367.119
    Edge: Not Found
    Firefox: Not Found
    Safari: 17.4.1
  npmPackages:
    @emotion/react: ^11.11.4 => 11.11.4 
    @emotion/styled: ^11.11.0 => 11.11.0 
    @mui/base:  5.0.0-beta.37 
    @mui/core-downloads-tracker:  5.15.11 
    @mui/icons-material: ^5.15.11 => 5.15.11 
    @mui/lab: ^5.0.0-alpha.166 => 5.0.0-alpha.166 
    @mui/material: ^5.15.11 => 5.15.11 
    @mui/private-theming:  5.15.11 
    @mui/styled-engine:  5.15.11 
    @mui/system:  5.15.11 
    @mui/types:  7.2.13 
    @mui/utils:  5.15.11 
    @mui/x-data-grid:  6.19.5 
    @mui/x-data-grid-premium: ^6.19.5 => 6.19.5 
    @mui/x-data-grid-pro:  6.19.5 
    @mui/x-date-pickers:  6.19.5 
    @mui/x-date-pickers-pro: ^6.19.5 => 6.19.5 
    @mui/x-license-pro:  6.10.2 
    @mui/x-tree-view: ^6.17.0 => 6.17.0 
    @types/react: ^18.2.60 => 18.2.60 
    react: ^18.2.0 => 18.2.0 
    react-dom: ^18.2.0 => 18.2.0 
    typescript: ^5.3.3 => 5.3.3 

Search keywords: datagrid aggregation tree-data
Order ID: 64163

@gulicJan gulicJan added status: waiting for maintainer These issues haven't been looked at yet by a maintainer support: commercial Support request from paid users labels May 6, 2024
@zannager zannager 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 May 6, 2024
@michelengelen
Copy link
Member

Hey @gulicJan
This is not possible atm.
I can add this as a feature request to the board if you want.
That way the team can have a look and see if an addition of this feature makes sense.

@michelengelen michelengelen added status: waiting for author Issue with insufficient information customization: extend Logic customizability 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 May 7, 2024
@michelengelen michelengelen changed the title When using Datagrid's aggregation is it possible to somehow use group row's value instead of the aggregated one? [data grid] When using Datagrid's aggregation is it possible to somehow use group row's value instead of the aggregated one? May 7, 2024
@gulicJan
Copy link
Author

gulicJan commented May 7, 2024

Hey @gulicJan This is not possible atm. I can add this as a feature request to the board if you want. That way the team can have a look and see if an addition of this feature makes sense.

Please, that would be very useful.

If that's not possible, we have another way of going around this by skipping some rows from the aggregation - is that possible?

@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 labels May 7, 2024
@michelengelen
Copy link
Member

Hey @gulicJan This is not possible atm. I can add this as a feature request to the board if you want. That way the team can have a look and see if an addition of this feature makes sense.

Please, that would be very useful.

Got it. 👍🏼

If that's not possible, we have another way of going around this by skipping some rows from the aggregation - is that possible?

Well, you can always build your custom aggregation functions where you could use some conditions to skip aggregation for rows.

@michelengelen michelengelen removed the status: waiting for maintainer These issues haven't been looked at yet by a maintainer label May 7, 2024
@gulicJan
Copy link
Author

gulicJan commented May 7, 2024

Well, you can always build your custom aggregation functions where you could use some conditions to skip aggregation for rows.

How can I skip the row from the aggregation for example when row.shouldSkip === true?

I've found one way by using getCellValue like this:

export const sum: GridAggregationFunction = {
  label: 'Sum',
  getCellValue({ row }) {
    if (row.shouldSkip) {
      return null;
    }

    return row.cost;
  },
  apply: ...

but my problem with that is that im using this Sum aggregation function for multiple columns not only for cost so I can't find a way to make more general solution.

@michelengelen
Copy link
Member

It is not easy to build a general solution. That's true.
I would suggest to build a custom one only for the columns you need it for and leave the rest as is. I will try and build an example later today and check back here.

@gulicJan
Copy link
Author

gulicJan commented May 8, 2024

It is not easy to build a general solution. That's true. I would suggest to build a custom one only for the columns you need it for and leave the rest as is. I will try and build an example later today and check back here.

That's true, but the "issue" is that the logic of skipping particular rows should be applied to every column and we have more than 40 of them. And also for later if we would add new columns in this case we would need also to create new aggregation functions for them.

Any luck with the solution?

@michelengelen
Copy link
Member

Any luck with the solution?

Just picked it up again ... I had some meetings yesterday and could not finish it. I will try now to find a good solution for that.

@michelengelen
Copy link
Member

Hey @gulicJan ... I finished the exploration and it is possible to exclude grouping rows (parent rows) from aggregation and still generalize them.

Here is an example.

Would this be solution you can work with?

@gulicJan
Copy link
Author

gulicJan commented May 8, 2024

Would this be solution you can work with?

It helps in some way, but there's still a question - is there a way to somehow flag specific children rows to be excluded from the aggregation?

In your case is it possible to somehow exclude favicon.ico size from the general aggregation?

image

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! customization: extend Logic customizability feature: Aggregation Related to the data grid Aggregation 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

3 participants