JqG​​rid Reload无法正常工作

时间:2010-08-09 15:57:56

标签: 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});
});  

如果有人可以帮助我......

由于

1 个答案:

答案 0 :(得分:14)

jqGrids都有参数loadonce: true。这意味着在首次加载后,datatype网格将从"json"更改为"local"。要重新加载第二个网格,您应该将datatype参数重置为"json"以及urlpage个参数。