问题
I am trying the validate the slickgrid rows, get the errored ones and trying to highlight the cells this way:
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
}
}
In the grid options i have:
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"
};
The CSS i have added is
.errored {
background: #FF0000 !important ;
}
I am not sure why the highlighting is not working. Please help.
Thanks, Asha
来源:https://stackoverflow.com/questions/58342437/slickgrid-cells-are-not-highlighted