One of the columns is an ID of a record. Id has a certain format something like: XXXX-XXX-1 etc.
When sorting on this column values show as:
XXXX-XXX-1
XXXX-XXX-10
XXXX-XXX-2
XXXX-XXX-3
...
Is there a way to properly sort such that -10 appears after?
Thanks
1 Answer, 1 is accepted
0
Accepted
Plamen Lazarov
Telerik team
answered on 21 May 2015, 03:56 PM
Hello Bilal,
The reason for this behavior is because by default JavaScript sort() method sorts elements alphabetically. I would offer to take a look at Array.prototype.sort() article that explains the same.
I would suggest to take a look at columns.sortable.compare resource which gives the opportunity to specify custom sorting function. In order to sort numerically it would be necessary to implement a custom sorting logic.
Let us know if that helps.
Regards,
Plamen Lazarov
Telerik
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
One possible approach to modify the default sorting of the Kendo UI for Angular Grid component would be for the developer to utilize the built-in compare property of the SortDescriptor object and thus determine the sorting logic:
To better illustrate this suggestion, I am sending you a StackBlitz demo that demonstrates a possible approach for providing a custom compare function for the Grid's sorting: