Replies: 1 comment 3 replies
-
Sorry, I'd need more specifics than "not working well" in order to help. If you are providing your own sortingFn, it is up to that code to perform sorting correctly. Make a code sandbox reproducing the issue and I could help. |
Beta Was this translation helpful? Give feedback.
3 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
Currently, I am working on customizing the sorting function for certain column. However, it seems like not working well and I am pretty sure that the function could return properly (-1, 0, 1). The code snippet is as below:
`
const c_DateSortingFn = (rowA, rowB, col) => {
var dateA = rowA.original[col];
var dateB = rowB.original[col];
var _dateA = moment(dateA, "DD/MM/YYYY hh:mm:ss A", true);
var _dateB = moment(dateB, "DD/MM/YYYY hh:mm:ss A", true);
return _dateA.isAfter(_dateB) ? -1 : _dateB.isAfter(_dateA) ? 1 : 0;
}
const columns = [
...
{
accessorKey: "UPDATE_DATETIME",
header: "Last Update",
size: 200,
Cell:({cell}) => (cell.getValue() === null) ? (<> - </>) : cell.getValue(),
sortingFn : (rowA, rowB, columnId) => {c_DateSortingFn(rowA, rowB, columnId)}
},
...
];`
Did I missed out anything? Thanks for your time.
Beta Was this translation helpful? Give feedback.
All reactions