'How i can implement date range picker in MUI DataGridPro?
I want to implement a Date Range picker with DataGrid Pro can anyone help me?
Solution 1:[1]
To implement a date range picker on a cell in the data grid (assuming this is what you are meaning), you would implement the below code:
const datePickerColumn: GridColDef[] = [
{
field: 'dates',
headerName: 'Pick Date Range',
editable: true /* this needs to be set to allow editing */
type: 'date' /* needs to be set to get the date picker drop down*/
},
];
<DataGrid
rows={dateData}
columns={myDateColumns}
isCellEditable={(params) => params.row.dates} /* makes the specified column editable */
/>
Once implemented, you should now be able to double click on a cell and get a date picker widget.
For more information you can refer to the documentation here: https://mui.com/components/data-grid/editing/
Solution 2:[2]
What do you mean by Date Range picker?
Do you want to have a column containing a date range? If yes, it is better to have two columns. One for start-date the other for end-date
If you want to filter one date column by providing a range, you will have to make a custom filter operator handling multiple value
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | Colegit |
| Solution 2 | Alexandre Fauquette |
