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

[DataGridPremium] Use valueGetter to get row group keys #16016

Draft
wants to merge 3 commits into
base: master
Choose a base branch
from

Conversation

cherniavskii
Copy link
Member

Fixes #16015

@cherniavskii cherniavskii added bug 🐛 Something doesn't work component: data grid This is the name of the generic UI component, not the React module! plan: Premium Impact at least one Premium user feature: Row grouping Related to the data grid Row grouping feature labels Dec 27, 2024
@@ -1605,7 +1605,7 @@ describe('<DataGridPremium /> - Row grouping', () => {
expect(getColumnValues(1)).to.deep.equal(['', '0', '3', '', '1', '4', '', '2']);
});

it('should not use valueGetter to group the rows when defined', () => {
it('should use valueGetter to group the rows when defined', () => {
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It turned out that the current behavior was intentional.
I disagree with this, but maybe I don't see the full picture.
I know it's been 3 years 😅, but still – @flaviendelangle if you remember any additional details about this decision – please let me know 🙂

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We discussed it some time ago with @michelengelen and the problem is that I don't remember the reason why we did that 😆
But I remember we did it on purpose (maybe a bad one though).

@mui-bot
Copy link

mui-bot commented Dec 27, 2024

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

Generated by 🚫 dangerJS against f7bee11

@@ -230,7 +231,7 @@ export const getCellGroupingCriteria = ({
if (groupingRule.groupingValueGetter) {
key = groupingRule.groupingValueGetter(row[groupingRule.field] as never, row, colDef, apiRef);
} else {
key = row[groupingRule.field] as GridKeyValue | null | undefined;
key = getRowValue(row, colDef, apiRef) as GridKeyValue | null | undefined;
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

When the row grouping is initially enabled, the public methods aren't yet assigned to apiRef.
I extracted the getRowValue method to a function so I can still call it here.
This doesn't change the fact that the apiRef passed to valueGetter won't have public methods assigned yet.

This makes me think that we should assign the methods (at least some of them) before initialization 🤔


WDYT?

@cherniavskii cherniavskii requested a review from a team December 30, 2024 13:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug 🐛 Something doesn't work 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 plan: Premium Impact at least one Premium user
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[data grid] Row grouping doesn't work with derived columns (valueGetter)
3 participants