JqG​​rid Reload无法正常工作

use*_*306 2 php jqgrid

我遇到了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

  • @Will:不客气!在`jqGrid.trigger('reloadGrid')`之前设置url特定于问题,但在大多数情况下建议设置`page:1`.原因如下.让我们用户在数据刷新之前选择页码5,重新加载后总页数将为4.如果不重置`page`,用户可以在刷新后看到空页5并且不明白原因这个.要有这个问题,你可以在`reloadGrid`之前设置`page:1`.另见http://stackoverflow.com/questions/3807623/jqgrid-paging-question/3808014#3808014 (2认同)