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.
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);
Show activity on this post. var myGrid = $('#task-grid'), selRowId = myGrid. jqGrid ('getGridParam', 'selrow'), celValue = myGrid. jqGrid ('getCell', selRowId, 'HOURS');
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).
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.
Try this, It will return an array of selected rows' id.
var s;
s = jQuery("#yourGridName").jqGrid('getGridParam','selarrrow');
alert(s);
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With