Extract row index from slickgrid using a unique cell value

故事扮演 提交于 2019-12-12 16:51:25

问题


    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




回答3:


I know I'm late but may be with better solution?

grid.getData().getIdxById('UniqueFieldValue')



来源:https://stackoverflow.com/questions/18189722/extract-row-index-from-slickgrid-using-a-unique-cell-value

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