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

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

Closed
victorct-tradeengage opened this issue Aug 25, 2024 · 6 comments · Fixed by #14733
Labels
bug 🐛 Something doesn't work component: data grid This is the name of the generic UI component, not the React module! feature: Filtering on header Related to the header filtering (Pro) feature feature: Filtering Related to the data grid Filtering feature

Comments

@victorct-tradeengage
Copy link

victorct-tradeengage commented Aug 25, 2024

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 victorct-tradeengage added bug 🐛 Something doesn't work status: waiting for maintainer These issues haven't been looked at yet by a maintainer labels Aug 25, 2024
@github-actions github-actions bot added the component: data grid This is the name of the generic UI component, not the React module! label Aug 25, 2024
@victorct-tradeengage
Copy link
Author

This actually applies the same with booleans

@victorct-tradeengage victorct-tradeengage changed the title [bug] Numbers are returned as strings when filtering a DataGrid [bug] Numbers and boleans are returned as strings when filtering a DataGrid Aug 25, 2024
@michelengelen michelengelen changed the title [bug] Numbers and boleans are returned as strings when filtering a DataGrid [data grid] Numbers and booleans are returned as strings when filtering in a DataGrid Aug 26, 2024
@michelengelen michelengelen added feature: Filtering Related to the data grid Filtering feature feature: Filtering on header Related to the header filtering (Pro) feature labels Aug 26, 2024
@michelengelen
Copy link
Member

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

@github-project-automation github-project-automation bot moved this to 🆕 Needs refinement in MUI X Data Grid Aug 26, 2024
@michelengelen michelengelen removed the status: waiting for maintainer These issues haven't been looked at yet by a maintainer label Aug 26, 2024
@victorct-tradeengage
Copy link
Author

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

@k-rajat19
Copy link
Contributor

k-rajat19 commented Sep 4, 2024

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

@romgrk
Copy link
Contributor

romgrk commented Sep 18, 2024

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

Copy link

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.

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: Filtering on header Related to the header filtering (Pro) feature feature: Filtering Related to the data grid Filtering feature
Projects
Status: 🆕 Needs refinement
Development

Successfully merging a pull request may close this issue.

4 participants