JqG​​rid重新加载不起作用 [英] JqGrid Reload not working

查看:79
本文介绍了JqG​​rid重新加载不起作用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在Jqgrid上遇到问题,我在单个页面上有两个网格,并且在第一个网格的行上单击时需要重新加载第二个网格.

I'm having an issue with Jqgrid, I've got two grids on a single page and onclick on a row of the first grid needs to reload the second grid.

我100%确保正确配置了第二个网格,如果我手动传递了一个正确填充的硬编码ID.

I'm 100% sure the second grid is configured correctly is if I manually pass a hard coded id it populates correctly.

只是重新加载功能不起作用.请有人帮忙.下面是两个网格的jQuery代码

Just the reload function is not working. Please could someone assist. Below is the jquery code for both grids

$(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});
});  

请有人帮助我...

谢谢

推荐答案

两个jqGrids都具有参数loadonce: true.这意味着在第一次加载后,网格的datatype将从"json"更改为"local".要重新加载第二个网格,应将datatype参数与urlpage参数一起重置为"json".

Both jqGrids has parameters loadonce: true. It means that after the first loading the datatype of the grids will be changed from "json" to "local". To reload the second grid you should reset the datatype parameter to "json" together with url and page parameters.

这篇关于JqG​​rid重新加载不起作用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆