PDA

View Full Version : Quasi-number sorting in a grid



vicvolk
3 Mar 2013, 12:40 PM
Hello guys! Another problem I came across is sorting of quasi-numbers in a grid. I mean I have such values:
1.1
1.1.1
2.1
11.1

When I sort the column, by default I get:
1.1
1.1.1
11.1
2.1

But what is needed looks like this:
1.1
1.1.1
2.1
11.1

I know how to use sortType, but in this very case I do not know how to apply it. I tried to replace in a sorter all dots except the first one by empty space and sort it like numbers. But this does not work for me, the column is still sorting in a text manner.

Many thanks!
Victor

vicvolk
4 Mar 2013, 12:18 AM
I got it. If you come across the same issue, define sortType in the following manner:


sortType:function(value){var pos = value.search(/\./) + 1;var val = value.substr( 0, pos )+ value.slice( pos ).replace(/\./g, '');return parseFloat(String(val))}