JqGrid Row object in onSelectRow

How to get row object in row selected in jqGrid? I need an actual object, not a cellular value. I looked through the documentation, but could not find a method that would give me a row object. since I use custom formatting elements, cellValue will not work.

+6
source share
3 answers

If you are implementing a custom formatter and want to get the cell value in relation to getCell or getRowData you also need to execute the unformat function.

It's not clear what you mean by "I need the actual object, not the value of the cell." It is also unclear which datatype you are using, whether you use the loadonce: true parameter or not, and if you download data from the server, in what format the data will be sent to the server.

If you use datatype: 'local' or use loadonce: true , the internal data and _index will be populated. To get the raw data from the rowid grid, 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 do not use datatype: 'local' or use loadonce: true and load data from the server, you can save the object representing the data from the server response in a variable (in the object). The loadComplete event loadComplete has one data parameter, which is the source data sent from the server. Thus, you can save the data that you need in the object (on the map that receives the yut object from rowid) and use it inside the onSelectRow event onSelectRow .

+9
source

You can use the getInd and getLocalRow methods:

 onSelectRow: function(rowid) { var row = $(this).getLocalRow(rowid); // do something with row } 

http://www.trirand.com/jqgridwiki/doku.php?id=wiki:methods

+3
source

in my project:

 ondblClickRow : function(rowid,iRow,iCol,e) { $($("#completeDetail").getInd(rowid,true)).find(":first").click(); } 

This will solve the row increase so as not to find the row

use this function - getInd(rowid,rowcontent) .

This method returns the index of the row in the grid table indicated by id=rowid when rowcontent is set to false (default). If rowcontent is set to true, it returns a row row object. If rowid cannot be found, the function returns false.

+3
source

Source: https://habr.com/ru/post/899710/


All Articles