I'm trying sort numbers in Kendo using compare, goal is Position the Null Values Last When Sorting.
based on the example when I'm sorting the string values it is perfectly fine, but when I'm trying to apply it into a numbers, It's not working properly. Please see the image.
In example, the number 10 is considered as null.
Here is the example: https://dojo.telerik.com/ILipALAG/2
Here is the link from Kendo that I'm trying to use.
CodePudding user response:
Try this in your sortable.compare
function:
sortable: {
compare: function (a, b, desc) {
if (a.level === 10)
return desc ? -1 : 1;
else if (b.level === 10)
return desc ? 1 : -1;
else if (a.level === b.level)
return 0;
else if (a.level > b.level)
return 1;
else if (b.level > a.level)
return -1;
}
}
This should put the number 10 at the bottom.