I am having multiple jqGrids in my form. Now for multiple jqGrids in my form I am achieving it by including a js file which is having its content of jqGrid definition and the contents of that js file are as under:
var MyGridData = MyGridData || (function () {
var _args = {};
return {
init: function (Args){
_args = Args;
},
initiateGrid: function (){
this.fillGridSchema(_args[6]);
},
fillGridSchema: function (){
$('#' + _args[0]).jqGrid({
url: _args[1],
datatype: "json",
mtype: "POST",
ajaxGridOptions: {contentType: 'application/json; charset=utf-8' },
serializeGridData: function(postdata){
return JSON.stringify(postdata);
},
postData: {colOrder: _args[2], data: _args[3]},
search: true,
colNames: _args[4],
colModel: _args[5],
viewrecords: true,
pager: jQuery('#pager_' + _args[7]),
rowNum: 10,
rowList: [10, 20, 30, 40],
//further required jqGrid properties here for ex: sortorder, //loadonce, gridview, ignorecase, etc.
onSelectRow: function (rowId) {
if(_args[8] != ''){
var rowData = jQuery(this).getRowData(rowId);
var fn = window[_args[4]];
if(typeof fn === 'function'){
fn(rowData);
}
}
}
});
}
}
}
Now for generation of a jqGrid, the following code is being called:
MyGridData.init([
'GridName1', 'griddataurl', 'colOrder', 'postDataargs', 'colNames', 'colModel', 'ExtraParams', 'pager', 'onSelectRowfunction'
]);
MyGridData.initiateGrid();
Now the problem being faced by me is, I am filling my 2nd grid on rowselect of 1st grid, and I am programmatically making default selection of first row in my grids. So when the first row of 1st grid is being selected, then I am calling a function in onSelectRow of 1st grid so as to fill my 2nd grid as per the selection in my first grid in that function. But the problem is that the _args argument shows me the arguments of the 1st grid, when it is being called for the first time only. Second time when the onSelectRow of first grid is being called, it shows me the _args argument having the values of 2nd grid arguments instead of the arguments of the 1st grid. I am not able to find out the problem in it. Please tell me the solution to this if any one can find out the problem in it.