我的表单中有多个 jqGrid。现在对于我表单中的多个 jqGrid,我通过包含一个 js 文件来实现它,该文件具有 jqGrid 定义的内容,并且该 js 文件的内容如下:
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);
}
}
}
});
}
}
}
现在为了生成 jqGrid,正在调用以下代码:
MyGridData.init([
'GridName1', 'griddataurl', 'colOrder', 'postDataargs', 'colNames', 'colModel', 'ExtraParams', 'pager', 'onSelectRowfunction'
]);
MyGridData.initiateGrid();
现在我面临的问题是,我在第一个网格的 rowselect 上填充我的第二个网格,并且我正在以编程方式默认选择我的网格中的第一行。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. 但问题是 _args 参数只在第一次被调用时向我显示了第一个网格的参数。第二次调用第一个网格的 onSelectRow 时,它显示 _args 参数具有第二个网格参数的值,而不是第一个网格的参数。我无法找出其中的问题。如果有人能找出其中的问题,请告诉我解决方案。