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.53k stars 1.31k forks source link

[data grid] How to handle auto-generated rows? #14358

Closed shoxter closed 2 months ago

shoxter commented 2 months ago

The problem in depth

Hi MUI Support,

I'm encountering issues when using valueGetter, valueFormatter, and renderCell functions in a DataGrid where some rows are auto-generated (e.g., aggregation rows). For example, calling row.product.humanId within these functions works fine for normal rows, but breaks when the row is auto-generated, as those fields may not exist.

Is there a recommended approach to handle these errors without needing to add extensive checks in all column definitions to distinguish between auto-generated and normal rows?

Thanks for your help!

Your environment

`npx @mui/envinfo` ``` Don't forget to mention which browser you used. Output from `npx @mui/envinfo` goes here. ```

Search keywords: Auto-generated rows Order ID: 96266

romgrk commented 2 months ago

You can find the recommendation in the docs: https://mui.com/x/react-data-grid/column-definition/#autogenerated-rows

There is no way to avoid the checks, otherwise those cells wouldn't be configurable.

shoxter commented 2 months ago

I don't know how I couldn't find that. Thank you for your help.

github-actions[bot] commented 2 months ago

:warning: 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.

@shoxter: 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.