I am working with a table containing date objects, and I have transformed them for display using the following code:
{
key: "date",
formatter: (value, key, item) => {
return moment(value).format("L");
},
sortable: true
}
However, this transformation has caused issues with the sorting function because it is now a localized string. I am looking for a way to override this and return to sorting by dates, something like:
sortingKey: value=>value
Unfortunately, I haven't been able to find a solution that fits my requirements.
Update: I have managed to solve the sorting issue, but the solution feels a bit messy to me. A cleaner solution would have looked like this:
field: {
key: 'date',
sorter: (value, item, fieldMeta) => {
// return a comparison that reacts to <
// key matches fieldMeta.key
// default implementation
return fieldMeta.formatter ? fieldMeta.formatter(value, fieldMeta.key, item) : value;
}