zhaohuijiadelu
zhaohuijiadelu
采纳率100%
2017-07-11 02:07

jqgrid加载本地数据分页

2
  • 分页
  • jqgrid
已采纳

参照网上的例子,使用localReader分页

    var localData = {page: 1, total: 2, records: "2", rows: [{'type':'t1','id':'123','name':'测试'},{'type':'t2','id':'123222','name':'测试22'}]};
    var reader = {  
                  root: function(obj) { return localData.rows; },  
                  page: function(obj) { debugger;return localData.page; },   
                  total: function(obj) {  return localData.total; },  
                  records: function(obj) { return localData.records; },  repeatitems : false};
    $("#list2").setGridParam({data: localData.rows, localReader: reader}).trigger('reloadGrid');  

但是点击下一页,page页总是停留在初始化的第1页,如果初始化时2,就一直停留在第2页。求大神指教。

  • 点赞
  • 写回答
  • 关注问题
  • 收藏
  • 复制链接分享
  • 邀请回答

1条回答

  • showbo GoCityPass新加坡曼谷通票 4年前

    jqgrid不支持客户端数据分页
    http://www.trirand.com/jqgridwiki/doku.php?id=wiki:retrieving_data#json_data

     If we have defined a pager for grid with client side data, the buttons in pager are automatically disabled. In other words, the current release of grid does not support client side paging and serching.
    

    而且配置项是reader,不是localReader
    $("#list2").setGridParam({data: localData.rows, reader: reader}).trigger('reloadGrid');

    jqGrid JSON数据源读取器选项配置

    点赞 2 评论 复制链接分享

为你推荐