Skip to content

Commit

Permalink
update demo
Browse files Browse the repository at this point in the history
  • Loading branch information
cherniavskii committed Dec 31, 2024
1 parent d488547 commit 2cb3c17
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 18 deletions.
5 changes: 2 additions & 3 deletions docs/data/data-grid/custom-columns/EditingWithDatePickers.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ import { LocalizationProvider } from '@mui/x-date-pickers/LocalizationProvider';
import { DatePicker } from '@mui/x-date-pickers/DatePicker';
import { DateTimePicker } from '@mui/x-date-pickers/DateTimePicker';
import { AdapterDateFns } from '@mui/x-date-pickers/AdapterDateFns';
import InputBase from '@mui/material/InputBase';
import { enUS as locale } from 'date-fns/locale';
import format from 'date-fns/format';
import { unstable_useEnhancedEffect as useEnhancedEffect } from '@mui/utils';
Expand All @@ -36,7 +35,7 @@ const dateColumnType = {
})),
valueFormatter: (value) => {
if (value) {
return dateAdapter.format(value, 'keyboardDate');
return format(value, 'MM/dd/yyyy', { locale });
}
return '';
},
Expand Down Expand Up @@ -129,7 +128,7 @@ const dateTimeColumnType = {
})),
valueFormatter: (value) => {
if (value) {
return dateAdapter.format(value, 'keyboardDateTime');
return format(value, 'MM/dd/yyyy hh:mm a', { locale });
}
return '';
},
Expand Down
17 changes: 2 additions & 15 deletions docs/data/data-grid/custom-columns/EditingWithDatePickers.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ import { LocalizationProvider } from '@mui/x-date-pickers/LocalizationProvider';
import { DatePicker } from '@mui/x-date-pickers/DatePicker';
import { DateTimePicker } from '@mui/x-date-pickers/DateTimePicker';
import { AdapterDateFns } from '@mui/x-date-pickers/AdapterDateFns';
import InputBase, { InputBaseProps } from '@mui/material/InputBase';
import { enUS as locale } from 'date-fns/locale';
import format from 'date-fns/format';
import { unstable_useEnhancedEffect as useEnhancedEffect } from '@mui/utils';
Expand All @@ -41,24 +40,12 @@ const dateColumnType: GridColTypeDef<Date, string> = {
})),
valueFormatter: (value) => {
if (value) {
return dateAdapter.format(value, 'keyboardDate');
return format(value, 'MM/dd/yyyy', { locale });
}
return '';
},
};

const GridEditDateInput = styled(InputBase)({
fontSize: 'inherit',
padding: '0 9px',
});

function WrappedGridEditDateInput(props: TextFieldProps) {
const { InputProps, focused, ...other } = props;
return (
<GridEditDateInput fullWidth {...InputProps} {...(other as InputBaseProps)} />
);
}

function GridEditDateCell({
id,
field,
Expand Down Expand Up @@ -154,7 +141,7 @@ const dateTimeColumnType: GridColTypeDef<Date, string> = {
})),
valueFormatter: (value) => {
if (value) {
return dateAdapter.format(value, 'keyboardDateTime');
return format(value, 'MM/dd/yyyy hh:mm a', { locale });
}
return '';
},
Expand Down

0 comments on commit 2cb3c17

Please sign in to comment.