I have a grid in my application. It contains the field value stock. I want to sort the field in descending order. The stock field contains a value with a positive float number and negative float value and hyphen value. I want to always display all hyphen values in last rows. Can anybody tell me how to do this?
e.g
**stock** I want to sort in descending order
45.44 56.56
56.56 56.23
- 45.44
43.25 43.25
-23 -23
- -
56.23 -
Thanks
This is not the natural order. In natural order hyphens ( representing the value zero ) should come between positive and negative values.
To achieve such custom orders, ExtJs allows you to define a sorting function. In your store, you would define someting like :
sorters: [{
sorterFn: function(value1, value2){
if (value1 === value2) {
return 0;
}
if (value1 == '-') return -1;
if (value2 == '-') return 1;
return parseFloat(value1) < parseFloat(value2) ? -1 : 1;
}
}]