如果 jqxgrid 中的“单列”中没有数据,则突出显示整行

Highlight the entire row if there is no data in a Single Column in jqxgrid

本文关键字:显示 数据 中的 jqxgrid 单列 如果      更新时间:2023-09-26

我的要求是:

如果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>';
 }
};

你可以尝试这样的东西:单元格样式。此示例显示条件单元格格式设置。在您的情况下,您必须为所有网格列实现"cellclassname"函数。通过这样做,您将能够实现条件行格式。

如果你通过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 */
});