Reputation: 359
I use ag-grid and wrote 2 custom functions for sorting. In documentation I found sortingOrder. In example it is used like this: sortingOrder: ["desc", "asc", null]
. If I add in array my own functions sortingOrder: [() => customASC(), () => customDESC(), null]
it doesn't work. How i can use sortingOrder of custom functions?
Upvotes: 0
Views: 2363
Reputation: 452
Looking at the docs, you need to add your custom sorting functions as comparator
.
You don't need to put it in the sortingOrder
, but next to it - within columnDefs
. There isn't a concrete example for this, but you could try adding it to column definitions like this:
var columnDefs = [
{
headerName: "Date",
field: "date",
comparator: customComparator, // your custom comparing function
sortingOrder: ['desc', 'asc'] // override default sorting order
}
]
function customComparator() {
// your custom code here
}
You need to test whether the default behavior is as expected (i.e. 'asc > desc > null' according to your custom sorting, and then you should be able to re-arrange the order using sortingOrder
.
Upvotes: 2