Extract row index from slickgrid using a unique ce

2019-07-18 05:06发布

问题:

    rowname="r1";
    changes[1]["num1"] = "changed";
    grid.invalidateRow(1);
    grid.setCellCssStyles("highlight", changes);

    grid.render();

Is there a way to get the index of a row in slickgrid if I have a cell value of first column which is unique? In the above code I want to use as changes[rowindex]["num1"]="changed" where "num1" is my column name and "r1" is first column cell value.changes["r1"]["num1"]="changed" does not works.

回答1:

Do it like this...

for(var i=0; i<grid.getDataLength(); i++){
   if(grid.getData()[i].firstColumnID == 'firstColumnValue'){
       rowIndex = i;
   }
}


回答2:

getRowById(id) - Returns the index of a row with a given id



标签: slickgrid