Javascript 网格单元不会高亮显示

Javascript 网格单元不会高亮显示,javascript,slickgrid,Javascript,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 (!

我正在尝试验证平滑网格行,获取出错的行,并尝试以这种方式突出显示单元格:

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
        }
   }
我添加的CSS是

.errored {
         background: #FF0000 !important ;
 }
我不知道为什么高亮显示不起作用。请帮忙

谢谢,
Asha

您正在初始化
错误
作为对象,但将其当作数组使用。看看你的代码,我想你希望
错误
是一个对象数组,对吗?如果是这样,您需要更改
var errors={}
var错误=[]谢谢Clav,我已将其更改为var errors=[];但我无法突出显示出错的单元格
.errored {
         background: #FF0000 !important ;
 }