可能重复:
jqgrid client side sorting with server side paging - data disappears
我正在尝试在客户端进行排序,但在服务器端进行分页。 我试着遵循这个但它不适合我 http://www.trirand.com/blog/?page_id=393/help/using-client-side-sorting-but-server-side-paging-using-jqgrid/#p25269
我的版本是4.2.0
$(document).ready(function(){
$("#mygrid").jqGrid({
url:'http://localhost/data',
datatype: 'json',
mtype: 'GET',
colNames:['ID', 'User'],
colModel :[
{name:'id', jsonmap: 'cell.id', sorttype:'int'},
{name:'user', jsonmap: 'cell.user', sorttype:'text'},
],
jsonReader: { repeatitems: false },
pager: '#mypager',
viewrecords: true,
rowNum:30,
rowList:[30,100,1000],
gridview: true,
viewrecords: true,
sortable:true,
sortorder: 'desc',
height: "100%",
scrollOffset:0,
onSelectRow: function(id){
},
altRows : true,
altclass : 'oddRow',
gridComplete: function() {
$(".jqgrow:odd").hover(
function() { $(this).removeClass("oddRow");},
function(event) { $(this).addClass("oddRow");}
);
},
onPaging: function() {
$("#mygrid").setGridParam({datatype:'json'});
$("#mygrid").trigger("reloadGrid");
},
loadComplete: function () {
$("#mygrid").setGridParam({datatype:'local'});
$("#mygrid").trigger("reloadGrid");
},
});
$('#mygrid').jqGrid('filterToolbar', { searchOnEnter: true, enableClear: false });
});
答案 0 :(得分:1)
从那个链接的讨论主题 - 看来你缺少“loadonce:true”