-
-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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] Row grouping does not work with nested row values #13085
Comments
Hey @cbrainee and thanks for raising an issue here. |
@cbrainee could you make that sandbox public? I cannot access it |
@michelengelen Done |
OK, I see that it is not working the way one would expect. |
Hi, You need to use the And if some value have no org, they will remain at the top level (doc). Here is what the final column could look like: {
field: "customerOrg",
headerName: "Customer Org",
width: 150,
renderCell: (data) => {
if (data.rowNode.type === "group") {
return data.value;
}
return <p>{data.formattedValue}</p>;
},
valueGetter: (value, row) => {
return row.customerInfo?.customerOrg;
},
groupingValueGetter: (value, row) => {
return row.customerInfo?.customerOrg ?? 'No organization';
},
}, By the way, in the |
By the way, you might not do this in your real application, but |
@flaviendelangle Thanks for the help and suggestions. |
@cbrainee if this solution fits your use-case please feel free to close the issue. |
The issue has been inactive for 7 days and has been automatically closed. |
The problem in depth
I am unable to group rows with certain data structures.
I understand there are a couple ways to have data displayed within a cell.
Using just formatValue will not work for this case because I have rows which have events on them. I do this by returning a react component within the renderCell function.
In the documentation, it shows that if I want to have grouping for that column, I have to add something like this to the renderCell function:
The problem with this is, it only groups if the property used to get the value on the row matches the field name.
If the value in the row is nested or modified within the react component, grouping does not work for that column.
Below is some sample data.
I am able to group by status because the row values are one level deep.
However, I am not able to group by customer org because the values are nested within an object.
Your environment
`npx @mui/envinfo`
Search keywords: Row grouping, Premium plan
Order ID: 88342
The text was updated successfully, but these errors were encountered: