My jqGrid contains a special column whose value is generated by another value, like the Duration Span column, its real value is in seconds like 3690s, and I should transform it to a formmatted string ‘Hour : Minute : Second’, in this cause it is ‘1:1:30’. Now, I want to it works well in sortting, so I write a customize function to handle this:
1, Following code fragment is column definition:
{
name : 'time',
index : 'time',
align: 'center',
width : '12%',
sorttype : sortTimeFuc
}
2, Following code fragment is sort function:
var sortTimeFuc = (function(cell) {
var a = cell.split(':');
var value = parseInt(a[2]) + parseInt(a[1]) * 60 + parseInt(a[0]) * 3600;
return value;
});
But it work incorrectly as below:

Can anybody gives me help? Thanks so much.
It seems to me that you make some errors. First of all you should remove parentheses over the function. Unneeded parentheses can follow to invocation of the function. The second and the most important error which I see in your code is the usage of parseInt without the second parameter 10. The last error is the usage of
width : '12%'. jqGrid don’t support ‘%’ inside of width. Instead of that you can use justwidth: 12and specifywidthof the total grid or useautowidth: true. Because the optionshrinkToFit: trueis default option if will follow to scaling the width of the columns based on the total width of jqGrid andwidthproperty of the column, which will define the proportion between the columns.So the resulting code could be as the following
See the answer as an example of very close implementation of custom sorting.