Slickgrid cells are not highlighted

只谈情不闲聊 提交于 2019-12-13 20:17:30

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!