我遇到了Jqgrid的问题,我在一个页面上有两个网格,并且在第一个网格的一行上点击需要重新加载第二个网格.
我100%确定第二个网格配置正确,如果我手动传递一个硬编码的ID它正确填充.
只是重装功能不起作用.请有人帮忙.下面是两个网格的jquery代码
$(document).ready(function() {
jQuery("#list2").jqGrid({
url:'classes/ListServices.php',
datatype: "json",
mtype: 'POST',
colNames: ['Id','Description', 'Details', 'Cost in (R)'],
colModel: [
{name:'Id',index:'Id', align:"center", width:30},
{name:'Description',index:'Description', align:"center"},
{name:'Details',index:'Details', align:"left"},
{name:'Cost',index:'Cost',align:"center",width:30,formatter:'currency'},
],
width: 780,
height: 100,
rowNum:18,
pager: '#pager1',
loadonce: true,
sortname: 'id',
viewrecords: true,
sortorder: "asc",
caption:"Services List",
multiselect: false,
onSelectRow: function(ids) {
if(ids == null) {
ids=0;
if(jQuery("#list3").jqGrid('getGridParam','records') >0 ) {
jQuery("#list3").jqGrid('setGridParam',
{url:"subgrid.php?q=1&id="+ids,page:1});
jQuery("#list3").jqGrid.trigger('reloadGrid');
}
}
else {
jQuery("#list3").jqGrid('setGridParam',
{url:"subgrid.php?q=1&id="+ids,page:1});
jQuery("#list3").jqGrid.trigger('reloadGrid');
}
}
});
jQuery("#list2").jqGrid('navGrid','#pager2',
{edit:false,add:false,del:false,multipleSearch:true});
jQuery("#list2").jqGrid('filterToolbar',
{stringResult: true,searchOnEnter : false});
jQuery("#list3").jqGrid({
url:'classes/ListServicesDetails.php?Id=2',
datatype: "json",
mtype: 'POST',
colNames: ['Id','ServiceId', 'Description', 'Details', 'Cost in (R)'],
colModel: [
{name:'Id',index:'Id', align:"center", width:30},
{name:'ServiceId',index:'ServiceId', align:"center", width:30},
{name:'Description',index:'Description', align:"center"},
{name:'Details',index:'Details', align:"left"},
{name:'Cost',index:'Cost',align:"center",width:30,formatter:'currency'},
],
width: 780,
height: 200,
rowNum:18,
pager: '#pager2',
loadonce: true,
sortname: 'id',
viewrecords: true,
sortorder: "asc",
caption:"Services Details List",
multiselect: false,
onSelectRow: function(id) {
alert(id);
}
});
jQuery("#list3").jqGrid('navGrid','#pager2',
{edit:false,add:false,del:false,multipleSearch:true});
});
Run Code Online (Sandbox Code Playgroud)
如果有人可以帮助我...
谢谢
Ole*_*leg 14
两个jqGrids都有参数loadonce: true.这意味着在第一次加载datatype后,网格将从更改"json"为"local".要重新加载第二个网格,您应该将datatype参数重置为和参数"json"一起.urlpage