I’m using
getGridParam('selarrrow');
to get the rows that are selected,where the method returns me the selected row ids according to their selection,but I want the ids according to their index.Do I have to write a method to sort the ids or is there a inbuilt method which returns me the selected row ids in order of their indexes.
thanks in advance
If you mean the index of the row in the grid then you have to resort the array or id returned by
$("#gridId").jqGrid("getGridParam", "selarrrow"). You can use sort() method ofArraywith your custom sort function. You can just use the fact that ids are the ids of<tr>elements. So the DOM elements of<tr>has native implemented rowIndex property which you can get by$("#"+rowid)[0].rowIndex.In the simplified form the code could be about the following
or you can use namedItem method instead
Probably you should include more verification in the code to be sure that the item with id will be found and it has the
rowIndexproperty.