It's very simple. The second optional option parameter of getRowData
method is rowid of the row which data is requested (see the documentation). So you can use
var selRowId = myGrid.jqGrid("getGridParam", "selrow");
to get last selected rowid first and then get the data of the row by
var rowData = myGrid.jqGrid("getRowData", selRowId);
If you use datatype: "local"
or some remote datatype
("xml"
or "json"
), but with loadonce: true
then jqGrid hold the data internally in data
array. In the case the usage of getLocalRow
method is more effective as the usage of getRowData
:
var rowData = myGrid.jqGrid("getLocalRow", selRowId);
If you use multiselect: true
option then jqGrid supports selarrrow
array of selected rowids and you can get all required data in the loop:
var i, selRowIds = myGrid.jqGrid("getGridParam", "selarrrow"), n, rowData;
for (i = 0, n = selRowIds.length; i < n; i++) {
rowData = myGrid.jqGrid("getLocalRow", selRowIds[i]);
// one can uses the data here
}
id
is the selected rows, id inonSelectRow: function (id, status, e) { ... }
– Endymion