How do I get row object on row selected in jqGrid? I need the actual object, not the cellvalue. I have gone through the documentation but could not find a method that will give me the row object. since I use custom formatters, the cellValue will not work.
If you implement custom formatter and want to get the cell value with respect of getCell or getRowData you have to implement unformat function also.
It is not clear what you mean under "I need the actual object, not the cellvalue". It is also unclear which datatype
you use, whether you use loadonce: true
option or not and if you load the data from the server in which format the data will be posted to the server.
If you use datatype: 'local'
or use loadonce: true
the internal data
and _index
parameters will be filled. To get raw data from the grid by rowid
you can use
var rowData = this.p.data[this.p._index[rowid]]
or
var grid = $(this),
localdata = grid.jqGrid('getGridParam', 'data'),
indexes = grid.jqGrid('getGridParam', '_index'),
rowData = localdata[indexes[rowid]];
If you don't use datatype: 'local'
or use loadonce: true
and load the data from the server only you can save the object represented the data from the server response in a variable (in an object). The loadComplete
event handler has one data
parameter which is the raw data posted from the server. So you are able to save the data which you need in a object (in a map which will get yut object by rowid) and use it inside of the onSelectRow
event handler.
loadonce: true
and small rowNum
(the page size) in case if the total number of rows less as 1000 or even 10000. For example the demo uses 4000 rows, 13 columns and 20 rows in a page and another demo display 40000 rows. You can try to sort, page and filter the grid to see the performance. –
Schlesinger You can use the getInd and getLocalRow methods:
onSelectRow: function(rowid) {
var row = $(this).getLocalRow(rowid);
// do something with row
}
in my project:
ondblClickRow : function(rowid,iRow,iCol,e) {
$($("#completeDetail").getInd(rowid,true)).find(":first").click();
}
This would solve the row increase not find looking for the row
use this function -> getInd(rowid,rowcontent)
.
This method returns the index of the row in the grid table specified by id=rowid
when rowcontent set to false (default). If rowcontent is set to true, it returns the entry row object. If the rowid can not be found, the function returns false.
© 2022 - 2024 — McMap. All rights reserved.
getLocalRow
method. Look the answer or another one for some small code examples and additional information. The source code of the method is very small and I recommend you to read it too. – Schlesinger