Free丨晓 2011-10-26 18:29
浏览 295
已采纳

jqGrid分页、搜索异常

 

使用datatype: "local",JSON数据写在页面中时分页、搜索一切正常。 

但使用datatype: getProducts, 时点击搜索、排序时数据每次拷贝了一份,(即:原数据有10条,操作后就成20条。。。。)。不知道哪位大仙遇见过没? 

 

<script type="text/javascript">
            jQuery(document).ready(function(){
                    jQuery("#toolbar").jqGrid({ 
                    //url:'/getJgGridDatas/', 
                    datatype: getProducts,
                    height: 500,
                    width: 1050, 
                    colNames:['地市','县区', '历史','中英文', '人数','类型', '公式','趋势', 'Hel','物理', 'Part'], 
                    colModel:[ 
                            {name:'Name',index:'bureauName', width:50,rowspan:2}, 
                            {name:'ssdName',index:'bscName', width:150}, 
                            {name:'editi',index:'editionName', width:60,align:"center"}, 
                            {name:'China_English_Name',index:'China_English_Name', width:50,align:"center"}, 
                            {name:'fn_Num',index:'fn_Num', width:50,sorttype:'int',align:"center"}, 
                            {name:'business',index:'business_type', width:50,align:"center"}, 
                            {name:'Num',index:'bts_Num', width:50,align:"center"}, 
                            {name:'sdf_Num',index:'cdmach_Num', width:50,align:"center"}, 
                            {name:'dfdf_type',index:'abis_type', width:50,align:"center"}, 
                            {name:'rew_an_type',index:'bsc_an_type', width:50,align:"center"}, 
                            {name:'ddf_type',index:'a_type', width:50,align:"center"} 
                        ], 
                    rowNum:20, 
                    rowTotal: 20, 
                    rowList : [20,40,60], 
                    loadonce:false, 
                    mtype: "GET", 
                    rownumbers: true, 
                    rownumWidth: 40, 
                    gridview: true, 
                    pager: '#ptoolbar', 
                    sortname: 'bureauName',
                    viewrecords: true, //是否显示行数
                    sortorder: "asc", 
                    caption: "实例" 
                });
                
                jQuery("#toolbar").jqGrid('navGrid','#ptoolbar',{del:false,add:false,edit:false,search:true}); 
                jQuery("#toolbar").jqGrid('filterToolbar',{stringResult: true,searchOnEnter : false}); 
            })
            
            function successFunction(jsondata) {
                var a = eval(jsondata);
                var m = a.rows;
                for(var i=0;i<=m.length;i++){
                    jQuery("#toolbar").jqGrid('addRowData',i+1,m[i]);
                }
            }
            
            function getProducts() {
                $.ajax({
                    url: '/myInfo_Ajax/?ids={{ids}}',
                    data: "{}",  ,
                    dataType: "json",
                    type: "POST",
                    contentType: "application/json; charset=gbk",
                    success: successFunction
                });
            }
        </script>


 

  • 写回答

1条回答 默认 最新

  • conanca 2011-10-27 09:22
    关注

    你的successFunction里加在第一行这么一句,应该能够解决你的问题:
    jQuery("#toolbar").clearGridData()

    但是我不明白你为什么用datatype: getProducts,这种自定方式获取后台数据自己来添加行呢。
    为何不直接用:
    url:'/myInfo_Ajax/?ids={{ids}}',

    datatype: 'json',

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 LiBeAs的带隙等于0.997eV,计算阴离子的N和P
  • ¥15 关于#windows#的问题:怎么用WIN 11系统的电脑 克隆WIN NT3.51-4.0系统的硬盘
  • ¥15 matlab有关常微分方程的问题求解决,来真人,不要ai!
  • ¥15 perl MISA分析p3_in脚本出错
  • ¥15 k8s部署jupyterlab,jupyterlab保存不了文件
  • ¥15 ubuntu虚拟机打包apk错误
  • ¥199 rust编程架构设计的方案 有偿
  • ¥15 回答4f系统的像差计算
  • ¥15 java如何提取出pdf里的文字?
  • ¥100 求三轴之间相互配合画圆以及直线的算法