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.07k stars 1.26k forks source link

[data grid] Numbers and booleans are returned as strings when filtering in a DataGrid #14327

Open victorct-tradeengage opened 3 weeks ago

victorct-tradeengage commented 3 weeks ago

Steps to reproduce

Link to live example: link

Steps:

  1. Create A Datagrid with one column being a number or a boolean
  2. Filter the column.
  3. console.log the filterModel, using onFilterModelChange
  4. The value for that field, inside the filterModel is 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

victorct-tradeengage commented 3 weeks ago

This actually applies the same with booleans

michelengelen commented 3 weeks ago

Confirmed @victorct-tradeengage ... @cherniavskii could this be related to the recent changes for the localStorage issue?

victorct-tradeengage commented 3 weeks ago

@michelengelen I think it also applies to dates, will double check today

k-rajat19 commented 2 weeks ago

This happens with dates too, 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

romgrk commented 1 day ago

We should use the parser when it makes sense, probably in the input component change handler. Feel free to send a PR for this.