I have a DataGrid in Material UI, and one of my columns displays dates. Following the guidance from the Material UI documentation, I have set the type to "date" in the column array:
{
field: "submittedAt",
headerName: "Submitted",
minWidth: 150,
flex: 2,
type: "date",
headerClassName: "tableHeader",
cellClassName: "hoverPointer"
}
After that, I am converting timestamps to MM/dd/yyyy format using Luxon
if (r.data().submittedAt) {
const d = DateTime.fromMillis(r.data().submittedAt.toMillis());
requestedDate = d.toFormat('MM/dd/yyyy')
}
Then, I utilize requestedDate
to populate the cell value in the column. However, when I sort the data, the column still sorts based on a string comparator instead of by date:
https://i.sstatic.net/9T7PD.png
I'm unsure about what I might be doing wrong and haven't found much support in the documentation or previous posts. While I could change the date format to yyyy/MM/dd for the string comparator to work, I prefer the MM/dd/yyyy format for readability purposes. Additionally, since I need the column to be user-dynamically sortable, server-side sorting isn't a viable solution. Thank you in advance for any assistance.