Retrieving selected rows from jqGrid

Andrew Burns picture Andrew Burns · Aug 20, 2009 · Viewed 89k times · Source

I have jqGrid 3.5 (full) mostly working. I have it retrieving data with the multi-select option on. The one part I can not get to work is getting the selected rows. The docs state:

To obtain selected rows we can use getGridParam('selarrrow') method. Using our example we can write this:

jQuery("#grid_id").getGridParam('selarrrow');

which will return an array with the selected rows (i.e., ["11","9"] from the figure above). The values in array are the id's of the selected rows.

This does not work and returns an undefined value (yes I have rows selected). I also have xmlreader:id setup in my grid config.

Can someone point me to a direction to look? I have tried everything I can think of to no avail.

UPDATE: redsquare was correct about incorrect selectors. my containing div had the same ID as the grid, I noticed this when I went to check my setup code and the selector was table#results changed that and it all works. Thanks all. If you post an answer redsquare I will accept it as it is the correct answer.

Answer

av1987 picture av1987 · Sep 26, 2012

Try this, It will return an array of selected rows' id.

var s;
s = jQuery("#yourGridName").jqGrid('getGridParam','selarrrow');
alert(s);