Override the numeric sorting function in 1.10
Override the numeric sorting function in 1.10
I'm trying to convert an old application to use the new API. The data has a column that contains integer numbers and empty strings and I want the empty strings to be placed after the numbers when sorted ascending. The built in numeric sorting function will place the empty cells before the numbers.
In my old application, this was solved by overriding the built in numeric sorting algorithm but this seems difficult to do with the new algorithm with the built in handling of formatted number.
Does anyone have a solution to my problem?
Thanks in advance
// Kristoffer
This question has an accepted answers - jump to answer
Answers
One thing you can do is set the
columns.render
option of the column.When the
type
of the render is 'sort', return a value larger than you expect to exist in your table:Here's a working demo
Though I just realized... if you want this to happen whether it's ascending or descending... well then I'm not sure...
If you don't care about the formatting aspect, then the method using in 1.9 or just overwriting the built in sort functions should still work.
If you do care about the formatting aspect, your sorting functions will need to deformat the data.
Allan
Rhinos solution works for me. I changed the return value from 999999999 to Number.MAX_VALUE in my application to make it a little more flexible.
I tried to use my "old" method of overwriting the default sorting function but didn't get that to work. I will maybe do some more testing to see if I can figure out the problem.
i'll try it myself and see if I can figure out what is going on!
Allan