I have a currency field set up on a KendoUI Grid like so:
DailyPriceChange: { type: 'number' },
It's column definition is as follows (as suggested by numerous other posts available here and elsewhere):
{
title: 'Daily Price Change',
field: 'DailyPriceChange',
template: '#= IA.Kendo.Renderers.renderCurrency(DailyPriceChange) #',
attributes: { 'class': 'numeric' },
sortable: {
compare: function(a, b) {
return a === b ? 0 : ((a > b) ? 1 : -1);
}
}
}
As an aside, the columns for the grid are actually built up in a private function that is used to set the .columns property on the datasource. The template just adds some formatting, and is not of course the underlying value that is being sorted.
My issue is that with or without the custom sortable function object, the data does not sort ASC correctly in IE9+ or FireFox (even recent), but does quite well in Chrome (any recent version). I would like to debug into the custom sortable object in Chrome Developer Tools, but a breakpoint on the compare function body is never hit when sorting, which makes me wonder if the code is even being executed. I even tried adding an alert() inside the function, but it is never seen. However, I can see the function definition when I examine the sortable property of the column in Developer Tools.
I have made a work-around to set all null values to 0 when the data is fetched (by using the parse override in the fields spec), but that not acceptable to the user community.