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.
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
.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With