mui / mui-x

MUI X: Build complex and data-rich applications using a growing list of advanced React components, like the Data Grid, Date and Time Pickers, Charts, and more!
https://mui.com/x/
4.14k stars 1.29k forks source link

[data grid] `__row_group_by_columns_group__` should be an exported value #14470

Open jmeinerz opened 1 month ago

jmeinerz commented 1 month ago

Steps to reproduce

Link to live example: Not applicable

This is a development experience bug, not a user-facing one.

Current behavior

When using @mui/x-data-grid-premium, MUI creates a new column on a data grid when the defines a custom grouping.

That new column is filterable, and the filter's field is defined as __row_group_by_columns_group__. This string is not exported, and that makes it for a brittle developer experience. Updating MUI might silently break things.

Expected behavior

I want to be able to import a value special-cased by MUI for the column created by a user's grouping, so that I can handle it accordingly in my consuming application.

I want the application to exit fast and be explicit in case a MUI version bump makes my assumptions incorrect.

Context

No response

Your environment

Not applicable

Search keywords: row_group_by_columns_group group by filters

Search keywords:

flaviendelangle commented 1 month ago

Hi, Thanks for your feedback

It is exported in the GRID_ROW_GROUPING_SINGLE_GROUPING_FIELD variable. If you are using multiple grouping criteria, you can check the getRowGroupingFieldFromGroupingCriteria method.

@michelengelen if you want to double check :pray: This might not be properly documented.

jmeinerz commented 1 month ago

Thank you, @flaviendelangle ! I can confirm the variable does solve the issue. I'm sorry I didn't find it before opening this. Cheers :)

michelengelen commented 1 month ago

@flaviendelangle you are right ... this specific part is not well documented. I'll add this as a recipe issue to add an example for this. Thanks for pointing that out! 👍🏼