最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

javascript - Jqgrid pager not working with "local" dataType - Stack Overflow

programmeradmin1浏览0评论

Does Jqgrid allow us to add pager which we are using dataType local and don't want the whole data to be loaded at once. I am trying to do the same without success. It only shows the first page and show Page 1 Of 1 on the pager when there are many more records to be displayed.

Does Jqgrid allow us to add pager which we are using dataType local and don't want the whole data to be loaded at once. I am trying to do the same without success. It only shows the first page and show Page 1 Of 1 on the pager when there are many more records to be displayed.

Share Improve this question asked Apr 4, 2011 at 11:19 Sourabh NarayankarSourabh Narayankar 1982 silver badges10 bronze badges 1
  • I haven't encountered this problem. Could you show your .jqGrid() init code? – mVChr Commented Apr 4, 2011 at 11:21
Add a ment  | 

2 Answers 2

Reset to default 2

Probably you fill the grid contain in the wrong way. Look at the example to see how you can use data parameter of jqGrid.

I have this same issue. I have a "local" jqgrid setup and it's showing my data but the pager values aren't pletely accurate. Until I figured out that I needed to muck with the 'localReader' property. On the jqgrid wiki I saw that the jsonReader can have functions that define how to get the page, records, etc. It also states that the localReader can do whatever the jsonReader does so I gave it shot. Here's what I am doing.

var grid = $('#table').jqGrid({
  datatype: 'local',
  altRows: true,
  colModel: [
    {name: '0', label: "Name"},
    {name: '1', label: "Color"},
  ],
  pager: "#pager",
  rowNum: 15,
  sortname: '0',
  viewrecords: true,
  gridview: true,
  height: '100%',
  autowidth: '100%'
});

var reader = {
  root: function(obj) { return results.rows; },
  page: function(obj) { return results.page; },
  total: function(obj) { return results.total; },
  records: function(obj) { return results.records; },

grid.setGridParam({data: results.rows, localReader: reader}).trigger('reloadGrid');

My "results" is an object like this:

{page: "1", total: "70", records: "1045", rows:[.....]}

This seems to work as desired.

发布评论

评论列表(0)

  1. 暂无评论