<table id="grid-table"></table>
<div id="grid-pager"></div>
jaGrid默认GET请求,改成POST加JSON字符串形式分页。
1、 contentType指定为json :ajaxGridOptions : {contentType: "application/json"},
2、mtype 指定为POST请求
3、postDate 转字符串 serializeGridData
$("#grid-table").jqGrid({
ajaxGridOptions: {
contentType: "application/json",
},//post请求需要加
pager: '#grid-pager',
url: '/api/ykcenter/admin/sync/stkInBill',
datatype: "json",
mtype: "POST",//post请求需要加
postData :{id: $("#id").val(),text: $("#text").val()},
serializeGridData: function(postData) {
if (postData.searchField === undefined) postData.searchField = null;
if (postData.searchString === undefined) postData.searchString = null;
if (postData.searchOper === undefined) postData.searchOper = null;
return JSON.stringify(postData);
},//post请求需要加
loadui: 'disable', //禁用加载提示
rowNum: 10, //每页显示记录数
colNames: [...省略], //数据列名称(数组)
colModel: [... ],//数据列各参数信息设置
width:"100%",
autowidth: true, //自动匹配宽度
gridview: true, //加速显示
viewrecords: true, //显示总记录数
multiselect: false, //可多选,出现多选框
multiselectWidth: 25, //设置多选列宽度
sortable: false, //可以排序
jsonReader: commonJsonReader,
shrinkToFit: false,
autoScroll: true,
loadComplete: function (result) {
resolvePagedResult4JQGrid(this, result);
H5Utility.busy(false);
}, onSelectRow: function () {
pageIndex = $("#" + this.id).getGridParam('page');
pageScrollPosition = $("#" + this.id).closest(".ui-jqgrid-bdiv").scrollTop();
}
});