我正在尝试验证slickgrid行,获取错误的行并尝试以这种方式突出显示单元格:
function validateGrid(){
var errors = {};
//Parse through the data grid
for (var i = 0; i < data.length; i++) {
//if errors row isnt present then create a row
if (!errors[i]) {
errors[i] = {};
}
var row = data[i];//select a row from data
//Check if acccount national or account regional is entered
if((row["SN0"].trim().length>0) || (row["SR0"].trim().length>0)){
if(row["M0"].trim().length==0 && row["D0"].trim().length==0){
errors[i]["M0"] = "errored";
errors[i]["D0"] = "errored";
errorOccured=true;
}
//This is re-render the rows
grid.invalidateRows(i);
}
}
//If error has occurred then highlight these rows
if(errorOccured){
grid.setCellCssStyles("highlight", errors);
grid.render();
console.log(JSON.stringify(errors));
}
else{
//Continue with saving the grid
}
}
在网格选项中,我有:
var options = {
enableCellNavigation: true,
enableColumnReorder: false,
createPreHeaderPanel: true,
showPreHeaderPanel: true,
preHeaderPanelHeight: 23,
editable:true,
explicitInitialization: true,
asyncEditorLoading: false,
editCommandHandler: queueAndExecuteCommand,
autoEdit: true,
enableColumnReorder: false,
frozenRow: 0,
cellHighlightCssClass: "errored"
};
我添加的CSS是
.errored {
background: #FF0000 !important ;
}
我不确定为什么突出显示不起作用。请帮忙。
谢谢, 阿莎