使用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>