如何在Jgrid中实现客户端排序和服务器端分页。
输出是Json Response容器10记录的1000。所以我的查询是只想排序当前页面上显示的10条记录。并非所有记录都应该排序。
请找到以下代码:
jQuery("#SubConGrid").jqGrid({
datatype: '',
height: 230,
width: 300,
colNames: ['SubcontractorID', 'Name', 'Type', 'RCBCode'],
colModel: [
{ name: 'SubcontractorID', index: 'SubcontractorID', width: 100, sortable: false, hidden: true },
{ name: 'Name', index: 'Name', width: 200, sorttype: "text", formatter: 'showlink', formatoptions: { baseLinkUrl: 'javascript:', showAction: "SelectContractor('", addParam: "');"} },
{ name: 'Type', index: 'Type', sorttype: "text", width: 50 },
{ name: 'RCBCode', index: 'RCBCode', width: 50, sorttype: "text" },
],
multiselect: false,
caption: "SubContractor",
pager: jQuery('#pageNavigation'),
viewrecords: true,
scrollrows: true,
shrinkToFit: true,
rowNum: 10,
sortable: true,
sortname: 'Name',
sortorder: 'desc',
rowList: [10, 15, 20],
pgbuttons: true,
pgtext: "Page {0} of {1}",
altRows: true,
onPaging: function (pgButton) {
GetSearchData();
}
});
function GetSearchData() {
PageMethods.GetSubContractorSearch( $("#SubConGrid").getGridParam("page"),
$(".ui-pg-selbox").val(), onGetListSuccess, onError);
}