Skip to content

Commit

Permalink
extract formatter
Browse files Browse the repository at this point in the history
  • Loading branch information
cherniavskii committed Nov 2, 2023
1 parent 15b524f commit 4f11d1f
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 12 deletions.
13 changes: 7 additions & 6 deletions docs/data/data-grid/filtering/QuickFilteringDiacritics.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,12 @@ import { DataGrid, GridToolbar } from '@mui/x-data-grid';
import FormControlLabel from '@mui/material/FormControlLabel';
import Switch from '@mui/material/Switch';

const dateFormatter = new Intl.DateTimeFormat('fr-FR', {
day: 'numeric',
month: 'long',
year: 'numeric',
});

const rows = [
{ id: 0, string: 'Café', date: new Date(2023, 1, 1), singleSelect: 'Jalapeño' },
];
Expand All @@ -13,12 +19,7 @@ const columns = [
field: 'date',
type: 'date',
width: 150,
valueFormatter: (params) =>
params.value.toLocaleDateString('fr-FR', {
day: 'numeric',
month: 'long',
year: 'numeric',
}),
valueFormatter: (params) => dateFormatter.format(params.value),
},
{
field: 'singleSelect',
Expand Down
13 changes: 7 additions & 6 deletions docs/data/data-grid/filtering/QuickFilteringDiacritics.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,12 @@ import {
import FormControlLabel from '@mui/material/FormControlLabel';
import Switch from '@mui/material/Switch';

const dateFormatter = new Intl.DateTimeFormat('fr-FR', {
day: 'numeric',
month: 'long',
year: 'numeric',
});

const rows = [
{ id: 0, string: 'Café', date: new Date(2023, 1, 1), singleSelect: 'Jalapeño' },
];
Expand All @@ -17,12 +23,7 @@ const columns: GridColDef[] = [
field: 'date',
type: 'date',
width: 150,
valueFormatter: (params) =>
params.value.toLocaleDateString('fr-FR', {
day: 'numeric',
month: 'long',
year: 'numeric',
}),
valueFormatter: (params) => dateFormatter.format(params.value),
},
{
field: 'singleSelect',
Expand Down

0 comments on commit 4f11d1f

Please sign in to comment.