2
    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.

zooney
  • 341
  • 6
  • 25

3 Answers3

0

Do it like this...

for(var i=0; i<grid.getDataLength(); i++){
   if(grid.getData()[i].firstColumnID == 'firstColumnValue'){
       rowIndex = i;
   }
}
Premshankar Tiwari
  • 3,006
  • 3
  • 24
  • 30
0

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

Jatin patil
  • 4,252
  • 1
  • 18
  • 27
  • It says the slickgrid has no method 'getRowById' ,can u give me a working code? – zooney Aug 14 '13 at 14:06
  • seems that your are not using `dataview` it will only work when you will use dataview as follows 'dataView.getRowById()' – Jatin patil Aug 14 '13 at 14:11
  • can u explain its complexity too?? I mean does it takes constant time to search the index? – zooney Aug 16 '13 at 15:32
  • for more on dataview visit http://stackoverflow.com/questions/12128680/slickgrid-what-is-a-data-view And https://github.com/mleibman/SlickGrid/wiki/DataView – Jatin patil Aug 18 '13 at 12:01
  • Hey thanx,also I am updating the slickgrid with the help of this: dataView.updateItem(args.item.id, row); But i have a number of rows to update simultaneously.So how can i update array of rows in dataview in slickgrid? – zooney Aug 27 '13 at 14:34
  • dataView.setItems(data); This will fire the change events and update the grid. – Jatin patil Aug 27 '13 at 15:47
0

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

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

Deepak Sharma
  • 4,124
  • 1
  • 14
  • 31