Jqgrid + sorting a number with spaces

I have a column in my JQgrid that says "size". The return type is integer. I added:

{
  name:'sizeKloc',
  index:'sizeKloc', 
  width:60, 
  editable:false, 
  sorttype: 'int', 
  align:'right'
},

There are cases where the value is passed as null.

My column has the following values: 0, 3, 5, empty (empty or white space), 1, empty (empty or white space), empty (empty or white space), 2, 3

But when I try to sort ASC, first the spaces should be followed by the actual sorting of the number, which is not executed.

Any help is appreciated.

+3
source share
1 answer

null 0, sorttype: 'int'. . , .

, ,

{name:'sizeKloc',index:'sizeKloc', width:60, editable:false, align:'right'
    sorttype: function (cellValue) {
        return cellValue === null ? -1000 : Number(cellValue);
    }},

{name:'sizeKloc',index:'sizeKloc', width:60, editable:false, align:'right'
    sorttype: function (cellValue) {
        var num = parseInt(cellValue, 10);
        return isNaN(num) ? -1000 : num;
    }},

.

+3

All Articles