0

我的要求是:

如果 jqx 网格中至少单列中没有数据,我需要突出显示整个行,有人可以帮帮我吗?

var cellsrenderer = function (row, columnfield, value, defaulthtml, columnproperties, rowdata) 
{    
 if (value > 2) 
 {
   return '<span style="margin: 4px; float: ' + columnproperties.cellsalign + '; color: #ff0000;font-weight:bold;">' + value + '</span>';
 }    
 else 
 {
    return '<span style="margin: 4px; float: ' + columnproperties.cellsalign + '; color: #00000;font-weight:normal;">' + value + '</span>';
 }
};
4

2 回答 2

0

如果你通过这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 */
});
于 2015-03-13T11:33:55.440 回答
0

您可以尝试类似的方法:Cells Styling。该示例显示条件单元格格式。在您的情况下,您必须为所有 Grid 列实现“cellclassname”功能。通过这样做,您将能够实现条件行格式。

于 2015-03-10T13:19:59.407 回答