I have an ag-grid (version 16) inside my Aurelia app. All columns are sortable. One of these columns needs custom sorting. As explained in the ag-grid documentation this is possible:
https://www.ag-grid.com/javascript-grid-sorting/#custom-sorting
They provide an example for javascript by using a comparator. It seems really simple at first.
When I try to use a comparator inside my own code (but this time using TypeScript), this code is just never reached (debugger instruction never called).
Below is my code:
constructor(...) {
this.columnDefs = [
{
headerName: "Name",
field: "name",
width: 150
},
...
{
headerName: "Indice",
field: "indice",
width: 90,
sort: 'desc',
comparator: (valueA, valueB) => this.indiceComparator(valueA, valueB);
}
}
private indiceComparator(valueA, valueB) {
debugger;
// Never reached !
return 0;
}
// When initializing my grid options
this.gridOptions.enableServerSideFilter = true;
this.gridOptions.enableFilter = true;
this.gridOptions.rowModelType = 'infinite';
I don't know where is the problem but I am using TypeScript and the example provided on the ag-grid website is using JavaScript.
Are you using a ServerSideDataSource? I don't think AG-Grid triggers the comparator when you use this. It does however triggers the getRows method again.