how can i add alternate background row in jqgrid?
A:
$("#myGrid").jqGrid({
...
gridComplete: function() {
var _rows = $(".jqgrow");
for (var i = 0; i < _rows.length; i += 2) {
_rows[i].attributes["class"].value += " alt";
}
}
});
Ngu Soon Hui
2009-11-23 11:24:24
*Way* too much work. This feature is already built into the grid. No need to reinvent it.
Craig Stuntz
2009-11-23 22:22:04
+2
A:
Look at the altRows
and altclass
options. Beware of the typically inconsistent capitalization!
Craig Stuntz
2009-11-23 22:22:57
A:
if you need to perform this dynamically (like when using the sortableRows functionality) you can call these two lines to reset the alternate color based on the jQueryUI css scheme:
$('#'+gridName+' tr:nth-child(even)').removeClass("ui-priority-secondary");
$('#'+gridName+' tr:nth-child(odd)').addClass("ui-priority-secondary");
Pete Amundson
2010-02-18 16:42:20