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

[DataGrid] Docs doesn't mention explicitly that date column requires Date object #10038

Closed
2 tasks done
tielushko opened this issue Aug 14, 2023 · 3 comments · Fixed by #10040
Closed
2 tasks done

[DataGrid] Docs doesn't mention explicitly that date column requires Date object #10038

tielushko opened this issue Aug 14, 2023 · 3 comments · Fixed by #10040
Labels
component: data grid This is the name of the generic UI component, not the React module! docs Improvements or additions to the documentation

Comments

@tielushko
Copy link

Duplicates

  • I have searched the existing issues

Latest version

  • I have tested the latest version

Steps to reproduce 🕹

Link to live example: https://codesandbox.io/s/filter-before-date-error-6mccmv?file=/Demo.tsx

Steps:

  1. Hit filter button in toolbar.
  2. Create a filter on column 'blah' type "is before" and type "05/01/2023"
  3. Noticed the value.getTime is not a function error in the console.
  4. Trying any different filter will not cause the issue to trigger.

Current behavior 😯

Cannot apply filter type "is before" on the timestamp date column.
Also seeing issue with timezone conversion when using "is" filter.

Expected behavior 🤔

I expect the "is before" to work and not throw such error.

Context 🔦

I am attempting to filter the date column. I tried to debug this a little bit and noticed how there's a different filter call for is before filter type in gridFilterOperations.ts type. gridDateOperators variable has an additional parameter in the before type that could be causing the trouble.

Your environment 🌎

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

Order ID or Support key 💳 (optional)

62502

@tielushko tielushko added the status: waiting for maintainer These issues haven't been looked at yet by a maintainer label Aug 14, 2023
@romgrk
Copy link
Contributor

romgrk commented Aug 14, 2023

The date type requires Date objects: https://codesandbox.io/s/filter-before-date-error-forked-q4tlfk?file=/Demo.tsx

In the doc we seem to mention that column types need a specific type but I don't see it listed which column type takes which value type.

https://mui.com/x/react-data-grid/column-definition/#converting-types

@romgrk romgrk added docs Improvements or additions to the documentation component: data grid This is the name of the generic UI component, not the React module! and removed status: waiting for maintainer These issues haven't been looked at yet by a maintainer labels Aug 14, 2023
@romgrk romgrk changed the title [data-grid-premium] value.getTime is not a function error when filtering with "before" filter type on timestamp "date" column type. [DataGrid] Docs doesn't mention explicitly that date column requires Date object Aug 14, 2023
@tielushko
Copy link
Author

@romgrk Thank you for your quick response. My next question however, when these timestamps are converted to date objects and formatted to be YYYY-mm-DD, it appears that the 'is' filter type is accounting for the local time zone instead of considering the time in UTC.

For example, filtering on 04/27/2023 will produce no results, but filtering on 04/26/2023 will produce all the values for 04/27/2023.

Is there a way to apply the filter in UTC? Thank you!

@romgrk
Copy link
Contributor

romgrk commented Aug 15, 2023

See #8855 for the UTC question. If you need more details ask there.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
component: data grid This is the name of the generic UI component, not the React module! docs Improvements or additions to the documentation
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants