各行とそのセルの内容をテストする場合は、次のようにして、各行を反復し、その行のテストされたセルが両方とも 0 の場合にセルを赤く着色します。
var rowIds = $(grid).jqGrid('getDataIDs');
for (i = 1; i <= rowIds.length; i++) {
rowData = $(grid).jqGrid('getRowData', i);
//check on TradeAmount and FoilTradeAmount Cells
//color background red if both are 0...the user should have to selecte a postive value of either cell
if (rowData['TradeAmount'] == 0 && rowData['FoilTradeAmount'] == 0) {
$(grid).jqGrid('setCell', i, 'TradeAmount', "", { 'background-color': '#F08080', 'background-image': 'none', 'font-weight': 'bold' })
.jqGrid('setCell', i, 'FoilTradeAmount', "", { 'background-color': '#F08080', 'background-image': 'none', 'font-weight': 'bold' });
} //if
else {
$(grid).jqGrid('setCell', i, 'TradeAmount', "", { 'background-color': '#5ccd06', 'background-image': 'none', 'font-weight': 'bold' })
.jqGrid('setCell', i, 'FoilTradeAmount', "", { 'background-color': '#5ccd06', 'background-image': 'none', 'font-weight': 'bold' });
}
} //for
列内のセルをスタイルしたいだけの場合は、次のようなことができます
.className td[aria-describedby="GridName_RowName"] {background-color: #F08080;}
次に、グリッドの初期化の一部として、各行をテストし、いくつかの条件が満たされた場合にクラスを追加します。
rowattr: function (rd) {//if the row is displaying an inactive user, give it a different CSS style
if (rd.CellName!= 0) { return { "class": "DeckListMissingAmount" }; } //if
},