How can I insert alternating row background color in jqgrid?
+1
A:
function applyZebra(containerId) {
$('#' + containerId + ' tr:nth-child(even)').addClass("jqgrow evenTableRow");
$('#' + containerId + ' tr:nth-child(odd)').addClass("jqgrow oddTableRow");
}
ContainerId is your jqgrid id. Call this method on the "gridComplete" event of your jqgrid.
Nrj
2009-11-22 08:36:25
Great solution, but it would be nice if the even/odd colors could be selected from the jQuery UI Theme.
Justin Ethier
2009-11-22 15:55:39
+2
A:
Look at the altRows
and altclass
options. Beware of the typically inconsistent capitalization! This does use the jQuery UI theme if you're using jqGrid 3.5 or higher.
Craig Stuntz
2009-11-23 22:30:35
+1
A:
To use the jQuery UI theme use this code:
$('#'+gridName+' tr:nth-child(even)').removeClass("ui-priority-secondary");
$('#'+gridName+' tr:nth-child(odd)').addClass("ui-priority-secondary");
I use this code when I perform manual sorting (drag-n-drop)
Pete Amundson
2010-02-18 15:44:04