You can use setCell inside the loadComplete event handler. The loadComplete event will be raised after the sorted data is loaded and after the data has been paged , so this is a good place to change the background color of the cell based on the current sort order:
loadComplete: function() {
var ids = grid.jqGrid('getDataIDs');
if (ids) {
var sortName = grid.jqGrid('getGridParam','sortname');
var sortOrder = grid.jqGrid('getGridParam','sortorder');
for (var i=0;i<ids.length;i++) {
grid.jqGrid('setCell', ids[i], sortName, '', '',
{style:(sortOrder==='asc'?'background:aqua;':
'background:yellow;')});
}
}
}
A working example that you can see live here .
UPDATED . Check out the modified demo . The results look more enjoyable than in the previous demo:

It shows the gradient effect in all browsers except opera. In opera, it is the same as the previous demonstration. In another answer, I play more with color gradient effects.
source
share