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] Support Date objects in filter model #7069

Merged
merged 6 commits into from
Dec 20, 2023

Conversation

cherniavskii
Copy link
Member

@cherniavskii cherniavskii commented Dec 2, 2022

Closes #6564

TODO:

  • add unit tests

Changelog

Breaking changes

  • The filterModel now supports Date objects as values for date and dateTime column types.
    The filterModel still accepts strings as values for date and dateTime column types,
    but all updates to the filterModel coming from the UI (e.g. filter panel) will set the value as a Date object.

@cherniavskii cherniavskii added breaking change component: data grid This is the name of the generic UI component, not the React module! feature: Filtering Related to the data grid Filtering feature enhancement This is not a bug, nor a new feature labels Dec 2, 2022
@mui-bot
Copy link

mui-bot commented Dec 2, 2022

@cherniavskii
Copy link
Member Author

It looks like there are no breaking changes here, since both Date and string values are accepted.

@github-actions github-actions bot added the PR: out-of-date The pull request has merge conflicts and can't be merged label Jan 2, 2023
@github-actions
Copy link

github-actions bot commented Jan 2, 2023

This pull request has conflicts, please resolve those before we can evaluate the pull request.

@cherniavskii cherniavskii changed the base branch from master to next December 16, 2023 15:24
To handle use cases where filter model was serialized and persisted in local storage for later use
Both date and string values are supported, but there's no reason to change the default.
@github-actions github-actions bot removed the PR: out-of-date The pull request has merge conflicts and can't be merged label Dec 16, 2023
@@ -18,131 +19,6 @@ import InputBase from '@mui/material/InputBase';
import locale from 'date-fns/locale/en-US';
import { styled } from '@mui/material/styles';

function buildApplyDateFilterFn(filterItem, compareFn, showTime = false) {
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a positive side-effect of this PR - we can now reuse the getGridDateOperators for pickers integration instead of rewriting all filter operators 🙂

@cherniavskii
Copy link
Member Author

It looks like there are no breaking changes here, since both Date and string values are accepted.

There was a breaking change in the filterModel: the value was set to the Date type when the change was coming from the filter panel. This was the reason I didn't merge the PR back then.

@cherniavskii cherniavskii marked this pull request as ready for review December 18, 2023 10:47
@cherniavskii cherniavskii merged commit 380f1bb into mui:next Dec 20, 2023
17 checks passed
@cherniavskii cherniavskii deleted the date-filtering branch December 20, 2023 20:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
breaking change component: data grid This is the name of the generic UI component, not the React module! enhancement This is not a bug, nor a new feature feature: Filtering Related to the data grid Filtering feature v7.x
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[DataGrid] Accept date objects in filter items
3 participants