Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

jqGrid - how to find iRow (index of the row) from rowId (table pri key)

Tags:

jquery

jqgrid

I have rows from a table in jqGrid. I manipulate the behaviour of cellEdit and now use it for editing. After I init the grid, I will use;

$('#grid').editCell(iRow,1,false);

to just select the cell.

but I have only rowId not iRow. How can I get iRow from rowId?

like image 484
Onur Eren Elibol Avatar asked Feb 06 '12 14:02

Onur Eren Elibol


1 Answers

The index of the row (iRow) you can get using rowIndex property of the DOM object which represent ther row <tr>. So you need just get the DOM of the row. If the rowId don't contain any meta-characters you can do just the following

var iRow = $('#' + rowId)[0].rowIndex;

For the more common case you can use jqID function which escapes the meta-characters if needed:

var iRow = $('#' + $.jgrid.jqID(rowId))[0].rowIndex;
like image 103
Oleg Avatar answered Oct 25 '22 03:10

Oleg