Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

JQgrid : specific value from a selected row

Tags:

jqgrid

how to get a value of a (hidden) column, from the selected row. that is, the cell value needs to be from the cell identied by colName, and the selected row (not using multi select). From the API i see the method getGridParam("selrow") for reading the row, may be able to combine with other methods.. but, any convenient method available? a code snippet would save lot of time... \ thanks.

like image 364
bsr Avatar asked Jun 11 '10 06:06

bsr


People also ask

How to get selected row data in jqGrid?

You can get the selected row indexes by using the selectedRowsIndexes property in Grid.

How to get particular column value in jqGrid?

I would recommend you to use getCol method (for example in the simplest form of usage: $("#list"). jqGrid("getCol", "columnName") ). It allows you to get an array of values from the specified column of the grid or to get an array of objects with id and value properties. See the documentation for more details.

How to get selected cell value in jqGrid?

First you can get the rowid of the selected row with respect of getGridParam method and 'selrow' as the parameter and then you can use getCell to get the cell value from the corresponding column: var myGrid = $('#list'), selRowId = myGrid. jqGrid ('getGridParam', 'selrow'), celValue = myGrid.

How can I select multiple rows in jqGrid?

To get the id of the selected row use the following code: var selectedRow = $("#grid_id"). jqGrid('getGridParam', 'selrow'); The code above will return the id of the selected row.


1 Answers

You should use getCell function to read the value from the cell identified by row id. So if you need a data from the column 'MyColName' of selected row you can do this with the following code:

var grid = jQuery('#list');
var sel_id = grid.jqGrid('getGridParam', 'selrow');
var myCellData = grid.jqGrid('getCell', sel_id, 'MyColName');

If you need read full data of a row you can use getRowData instead of getCell. More about methods supported by jqGrid you can read in the documentation (see http://www.trirand.com/jqgridwiki/doku.php?id=wiki:methods).

like image 181
Oleg Avatar answered Oct 18 '22 23:10

Oleg