[data grid] Numbers and booleans are returned as strings when filtering in a DataGrid
Steps to reproduce
Link to live example: link
Steps:
- Create A Datagrid with one column being a number or a boolean
- Filter the column.
- console.log the
filterModel, usingonFilterModelChange - The value for that field, inside the
filterModelis a string, not a number or a boolean.
Current behavior
Numbers and booleans are being returned as strings when filtering a DataGrid
Expected behavior
Numbers and booleans must be returned as numbers or booleans when filtering a DataGrid
Context
No response
Your environment
npx @mui/envinfo
- System:
- OS: macOS 14.0
- Binaries:
- Node: 19.5.0 - ~/.local/share/nvm/v19.5.0/bin/node
- npm: 9.3.1 - ~/.local/share/nvm/v19.5.0/bin/npm
- pnpm: Not Found
- Browsers:
- Chrome: 127.0.6533.120
- Edge: Not Found
- Safari: 17.0
- npmPackages:
- @emotion/react: 11.11.1
- @emotion/styled: 11.11.0
- @mui/base: 5.0.0-beta.40
- @mui/core-downloads-tracker: 5.15.15
- @mui/icons-material: ^5.14.11 => 5.14.11
- @mui/lab: ^5.0.0-alpha.148 => 5.0.0-alpha.150
- @mui/material: ^5.14.11 => 5.15.15
- @mui/private-theming: 5.15.14
- @mui/styled-engine: 5.15.14
- @mui/system: 5.15.15
- @mui/types: 7.2.14
- @mui/utils: 5.15.14
- @mui/x-data-grid: 7.3.1
- @mui/x-data-grid-generator: ^7.3.1 => 7.3.1
- @mui/x-data-grid-premium: ^7.6.1 => 7.6.1
- @mui/x-data-grid-pro: 7.3.1
- @mui/x-date-pickers: ^6.17.0 => 6.17.0
- @mui/x-license: ^7.2.0 => 7.2.0
- @mui/x-tree-view: 6.0.0-alpha.1
- @types/react: ^18.0.14 => 18.0.14
- react: ^18.2.0 => 18.2.0
- react-dom: ^18.2.0 => 18.2.0
- typescript: ^4.7.4 => 4.7.4
Search keywords: number, filter, string, DataGird Order ID: I have a license key for the premium, not can share the email if needed, not sure how to get the OrderID
This actually applies the same with booleans
Confirmed @victorct-tradeengage ... @cherniavskii could this be related to the recent changes for the localStorage issue?
@michelengelen I think it also applies to dates, will double check today
This doesn't happen with dates, internally we are converting those string values into the other types (using valueParser property in colDef) before applying the filter operator to them.
@cherniavskii @romgrk should we use that valueParser more at the top level ? and update the value types in the filter model, then we also don't need to parse the values internally again.
happy to send PR for that
We should use the parser when it makes sense, probably in the input component change handler. Feel free to send a PR for this.
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.
[!NOTE] @victorct-tradeengage 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.