如果你通过这cellclassname
条路线,你可以尝试这样的事情:
var cellClass = function(gridId, highlightClass) {
highlightClass = highlightClass || 'default';
return function(row, columnfield, value) {
return hasEmptyCell(gridId, row) ? highlightClass : '';
// where hasEmptyCell is a function that checks if a row has an empty cell
};
};
var cols = [
{ text: 'Product Name', datafield: 'ProductName', width: 250 },
{ text: 'Quantity per Unit', datafield: 'QuantityPerUnit', cellsalign: 'right', align: 'right', width: 120 },
{ text: 'Unit Price', datafield: 'UnitPrice', align: 'right', cellsalign: 'right', cellsformat: 'c2', width: 100 },
{ text: 'Units In Stock', datafield: 'UnitsInStock', cellsalign: 'right', width: 100 },
{ text: 'Discontinued', columntype: 'checkbox', datafield: 'Discontinued' },
];
for (var i in cols) {
cols[i].cellclassname = cellClass('#test-grid', 'highlighted');
}
// then initialize jqxGrid using cols
$("#jqxgrid").jqxGrid({
columns: cols
/* ... other properties */
});