Hello everyone, I have a one-way plug
I receive information about the price in the min / max format
And how to sort on this field, he treats it as a string
And at the moment I do not even have thoughts on how best to do it.
Can rewrite Beck, or rewrite sorting function, who faced this?
thank you in advance
- he he treats it as a string , who is he? Bring the string to number and that's it - ThisMan
|
1 answer
I decided not to touch Beck and write it on the front
jQuery.extend( jQuery.fn.dataTableExt.oSort, { "signed-num-pre": function ( a ) { let index = a.indexOf('/'); let number = a.substring(0,index); return parseFloat(number); }, "signed-num-asc": function ( a, b ) { return ((a < b) ? -1 : ((a > b) ? 1 : 0)); }, "signed-num-desc": function ( a, b ) { return ((a < b) ? 1 : ((a > b) ? -1 : 0)); } } ); |