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

[docs] Using data grid with date pickers #5053

Merged
merged 15 commits into from
Jun 14, 2022

Conversation

cherniavskii
Copy link
Member

@cherniavskii cherniavskii commented May 30, 2022

Closes #4909 until we provide out of the box support for pickers in data grid

Preview: https://deploy-preview-5053--material-ui-x.netlify.app/x/react-data-grid/editing/#usage-with-mui-x-date-pickers

  • Use DatePicker for date column type
  • Use DatePicker for date column filter input
  • Use DateTimePicker for dateTime column type
  • Use DateTimePicker for dateTime column filter input

@mui-bot
Copy link

mui-bot commented May 30, 2022

These are the results for the performance tests:

Test case Unit Min Max Median Mean σ
Filter 100k rows ms 251.9 423.8 384.1 344.5 71.977
Sort 100k rows ms 455.7 827.1 682.2 661.88 125.42
Select 100k rows ms 99.7 188.7 176.8 143.8 33.773
Deselect 100k rows ms 102.1 205 197 173.64 39.243

Generated by 🚫 dangerJS against cc8e020

@cherniavskii cherniavskii added the docs Improvements or additions to the documentation label May 30, 2022
@cherniavskii cherniavskii marked this pull request as ready for review June 1, 2022 13:58
docs/data/data-grid/editing/editing.md Show resolved Hide resolved
export default function EditingWithDatePickers() {
return (
<div style={{ height: 300, width: '100%' }}>
<LocalizationProvider dateAdapter={AdapterDateFns}>
Copy link
Member

Choose a reason for hiding this comment

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

The date formats between view mode and edit are different. In view mode I see the dates as dd/mm/YYYY (same as new Date().toLocaleDateString()), but on edit mode it's mm/dd/YYYY). I think we should provide some instructions explaining that the date format must be changed according to the locale, or find a way to make it work automatically. Related to https://mui.com/x/react-date-pickers/localization/#date-engine-locale

Copy link
Member Author

Choose a reason for hiding this comment

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

Nice catch! I've used dateAdapter in valueFormatter to make sure data formats are the same in view and edit mode, even when locale is changed

Copy link
Member

Choose a reason for hiding this comment

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

Great, could you add a warning saying that the import must be changed to change the date format?

Copy link
Member Author

Choose a reason for hiding this comment

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

Done

@cherniavskii cherniavskii added component: data grid This is the name of the generic UI component, not the React module! customization: css Design CSS customizability labels Jun 10, 2022
Copy link
Member

@m4theushw m4theushw left a comment

Choose a reason for hiding this comment

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

Awesome!

There's only one detail left. The calendar button is overflowing and causing scrollbars. Increasing the right margin of the [aria-label="Choose date"] element seems to fix it.

image

docs/data/data-grid/editing/editing.md Outdated Show resolved Hide resolved
docs/data/data-grid/editing/editing.md Outdated Show resolved Hide resolved
docs/data/data-grid/editing/EditingWithDatePickers.tsx Outdated Show resolved Hide resolved
Copy link
Member

@joserodolfofreitas joserodolfofreitas left a comment

Choose a reason for hiding this comment

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

This is looking great! 👌

@cherniavskii cherniavskii merged commit 0d4ba3d into mui:master Jun 14, 2022
@cherniavskii cherniavskii deleted the data-grid-with-date-pickers branch June 14, 2022 11:24
@oliviertassinari
Copy link
Member

oliviertassinari commented Jun 20, 2022

As a side note, the font size in the textbox looks off the expected design values from the theme for native and non native date pickers:

Screenshot 2022-06-20 at 15 25 38

https://deploy-preview-5053--material-ui-x.netlify.app/x/react-data-grid/editing/#making-a-column-editable

Screenshot 2022-06-20 at 15 25 47

https://deploy-preview-5053--material-ui-x.netlify.app/x/react-data-grid/editing/#usage-with-mui-x-date-pickers

@oliviertassinari oliviertassinari added the component: DatePicker The React component. label Jun 20, 2022
@cherniavskii
Copy link
Member Author

@oliviertassinari Nice catch!

@Manisha11sep
Copy link

Manisha11sep commented Feb 8, 2024

@cherniavskii @cherniavskii Was it released? I am using v6 version of MUI but still, the date filter uses a native date picker from the browser.
This is from safari
Screenshot 2024-02-08 at 12 46 30 PM

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! component: DatePicker The React component. customization: css Design CSS customizability docs Improvements or additions to the documentation
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[data grid] How to apply the MUI-X Date Picker instead of the default date picker in the MUI X Data Grid?
6 participants