admin管理员组

文章数量:1415652

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.

本文标签: javascriptJqgrid pager not working with quotlocalquot dataTypeStack Overflow