Is not sorting by cell content possible?
I have table where a column is filled with dates as strings. I get the dates from my backend in the ISO 8601 format as strings. Now I have a function, that converts them into the new format 'DD.MM.YYYY hh:mm:ss'. With that new format the sorting doesn't work anymore as I want (obviously because it is first sorting by the Day and not by year and then month). So is it possible to sort by the ISO format, but display the other format?
In addition to this I have a global sort, which should use the new format and not the ISO one.
I know this is maybe really tricky and not expected to work like that, so if this is not possible I fully understand, but it would be great if there is a solution to this.
5 Replies
crude-lavender•15mo ago
On the accessor leave the date in ISO and in the cell callback return the formatted date string. Then sorting on the column will use the accessor value.
xenophobic-harlequinOP•15mo ago
Thank you for your answer. I already had that, but then the global search also uses the ISO format, which I don't want. Or am I seeing this wrong?
robust-apricot•15mo ago
Hi, I have the same issue right now. I'm poking around to find a way to get search and sort working correctly for dates. My backend also returns dates as ISO formatted strings. I'll post here if I find anything.
metropolitan-bronze•15mo ago
The sorting features sort by whatever you accessors access. Optimize your accessorFn or accessorKey for what you want to process the data on. Use a custom
cell
render to change the value for display purposes.xenophobic-harlequinOP•15mo ago
The Problem is not, that we can't sort. The Problem is, that we can't have a parallel sort and filter function set for if we use a date, that changes its format. If we use the ISO date in as the accessor the sorting works, but the filter is not logical to use. If we use the reformatted date as the accessor the filter works, but not the sorting.