Monday, June 3, 2024
 Popular · Latest · Hot · Upcoming
26
rated 0 times [  33] [ 7]  / answers: 1 / hits: 12996  / 11 Years ago, wed, december 11, 2013, 12:00:00

I am developing an ASP.NET mvc project which uses JqGrid for generating report. For report generation i am generating 2 different reports . Second report will be generated based on the values of First report.
For getting column values i am using OnCellSelect event of JqGrid,



Event:



$('#Report1').jqGrid({
...
..
colNames: ['name1','name2','name3','name4','name5','name6','name7'],
colModel: [
{....},
{ ... },
{ ...},
{...},
{ ...},
{ ...},
{ ... }
],
jsonReader: {
root: 'DD_data',
id: 'name1',
repeatitems: false
},
pager: $('#pager'),
//Event fires when clicked on name7
onCellSelect: function (rowid, index, contents, event) {

//Code for generating Second Report based on First report data//
$('#Report2').jqGrid({
...
...
});
}
});


Here in Cell Select event i am only getting rowid , my key , and selected cell content.



But i also need name2,name3 and name4 data from the selected column to generate second Report.



Is it possible in JqGrid.



Any help is appreciated.


More From » jqgrid

 Answers
10

You can use getCell or getRowData to get the data from the row based on rowid. If you use datatype: local or if you use loadonce: true option in the grid #Report1 then you can use getLocalRow which have some advantages over getRowData, but works only if the data are saved locally inside of internal data parameter. The parameter will be filled only if datatype is not json or xml or if it's json or xml, but loadonce: true option are used.



The simplest code which you can use would be



onCellSelect: function (rowid) {
var rowData = $(this).jqGrid(getRowData, rowid);
// now you can use rowData.name2, rowData.name3, rowData.name4 ,...
}


Usage of getLocalRow could have some advantages (including performance advantage), but you should verify whether it works together with datatype and loadonce which you use in the grid #Report1.


[#49643] Tuesday, December 10, 2013, 11 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
megb

Total Points: 230
Total Questions: 113
Total Answers: 100

Location: Tokelau
Member since Sun, May 7, 2023
1 Year ago
;