Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Retrieving selected rows from jqGrid

Tags:

jquery

jqgrid

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.

like image 385
Andrew Burns Avatar asked Aug 20 '09 21:08

Andrew Burns


People also ask

How to get selected row data from jqGrid?

In JavaScript: var rowid = $('#YourGridId'). jqGrid('getGridParam', 'selrow'); // assign the value from a cell in the selected grid row to a variable of your choice: var YourCellValue = $('#YourGridId'). jqGrid('getCell', rowid, 'YourCellId') alert(YourCellValue);

How can I select multiple rows in jqGrid?

Show activity on this post. var myGrid = $('#task-grid'), selRowId = myGrid. jqGrid ('getGridParam', 'selrow'), celValue = myGrid. jqGrid ('getCell', selRowId, 'HOURS');

How do I select a row in jqGrid programmatically?

UPDATE: Free jqGrid supports multiPageSelection:true option strarting with the version 4.10. 0. The option allows to set selection of multiple rows in the grid very easy (and it works very quickly, because it set selection state directly during creating the body of the grid).

How to get particular column value in jqGrid?

jqGrid ('getGridParam', 'selrow'); var cellVal = myGrid. jqGrid ('getCell', rowID, 'colName'); var row = myGrid. jqGrid ('getRowData', rowID); // This will return whole row data (or all columns value) var columnVal = row["ColumnName"]; // ColumnName is again name of column define in colModel array.


1 Answers

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

var s;
s = jQuery("#yourGridName").jqGrid('getGridParam','selarrrow');
alert(s);
like image 160
av1987 Avatar answered Oct 12 '22 13:10

av1987