The usage of the function afterInsertRow
is not the best way especially if you use gridview:true
jqGrid option which is almost always recommended. Look at the old answer which do mostly what you need. The schema of the code could be about following
var grid = $('#list'),
gridNode = grid[0];
grid.jqGrid({
//...
loadComplete: function() {
var ids = grid.jqGrid('getDataIDs');
for (var i = 0, l = ids.length; i < l; i++) {
var rowid = ids[i];
// get data from some column 'readStatus'
var status = grid.jqGrid('getCell',rowid,'readStatus');
// or get data from some
//var rowData = grid.jqGrid('getRowData',rowid);
// now you can set css on the row with some
if (status === 'error') {
$('#' + rowid, gridNode).addClass('myErrorClass');
}
}
}
});
It looks like "transversing the DOM after grid has completed", but it works quickly as the usage of afterInsertRow
.