1

When I have no rows returned, our jqGrid pager says Page 1 of NaN.

The JSON returned is:

{"page":"1","records":"0","total":"1"}

Why is NaN listed?


Update: We only seem to have this issue when we use loadonce:true.

Here's the source code:

  $("#list").jqGrid({
    url:'NoData.json',
    datatype: 'json',
    mtype: 'GET',
    colNames:['Product', 'Type'],
    colModel :[
      {name:'product', index:'product', width:80},
      {name:'type', index:'type', width:55, align:'right'},
    ],
    pager: '#pager',
    rowNum:20,
    viewrecords: true ,
    caption: 'Positions',
    height: '460',
    loadonce:true,          
    hidegrid: false         
  });

Update 2: What seems to work is the JSON below - is this right?

{"page":0,"records":0,"total":0,"rows":[]}
Marcus Leon
  • 55,199
  • 118
  • 297
  • 429

3 Answers3

3

Something is wrong in the definition of your jqGrid. Look at the simple example of jqGrid filled with your JSON data. You will see "No records to view" ar other text from $.jgrid.defaults.emptyrecords defined in grid.locale-XX.js (grid.locale-en.js for example).

If you will continue to have problem you should append your question with the code of the jqGrid having the described problem.

Oleg
  • 220,925
  • 34
  • 403
  • 798
  • Took a closer look - see the updated post. Only seem to have this issue when `loadonce` is true – Marcus Leon Sep 21 '10 at 13:32
  • I downloaded the example you mentioned - if I change loadonce to true then you can reproduce the issue. – Marcus Leon Sep 21 '10 at 13:46
  • 1
    @Marcus: I found the place where the error exist. In jqGrid 3.7.2 in grid.base.js the lines 1098 and 1239 which has `if(locdata) {` should be replaced to `if(locdata && rn) {`. You can see the same example with the fixed code under http://www.ok-soft-gmbh.com/jqGrid/NoData1.htm. The problem is that I find **MUCH MORE** problem in just published version of jqGrid 3.8. I have not a few time, but will try later write the corresponding suggestions how to fix the bugs in http://www.trirand.com/blog/?page_id=393/bugs/. – Oleg Sep 21 '10 at 14:47
  • 1
    @Marcus: I do took the time and posted http://www.trirand.com/blog/?page_id=393/bugs/nan-as-total-number-of-pages-for-jsonxml-data-with-0-rows/ which describes the found problems. – Oleg Sep 21 '10 at 15:08
  • Thanks Oleg. Is the workaround I posted in "Update 2" a valid workaround (if you don't want to modify the code)? Or is it better to do the code change? – Marcus Leon Sep 21 '10 at 15:22
  • @Marcus: I agree, if you can change your code to produce data with `"rows":[]` it could be a good workaround. – Oleg Sep 21 '10 at 16:27
0

It's trying to reference the first page of a recordset with no records.

Andy Evans
  • 6,997
  • 18
  • 72
  • 118
0

How about change the option "pgtext"?

pgtext: "Page {0}"