1

Issue: My jqGrid pager shows Page 1 of NaN instead of the correct number of pages.

Fiddler shows that I am getting the correct json from my WCF call:

{"total":1,"page":1,"records":2,"rows":[{JDEVendorNumber":99999999,
 "VendorName":"Super   Vendor","BillID":"99999999wwerer                      ",
 "CommunityName":"Post Abbey                              ",
 "PrimaryAcctNumber":"wwerer","CommunityID":"600402","RecordID":8}]}

My grid setup is as follows:

$invoiceGrid.jqGrid({
        datatype: 'json',
        mtype: 'GET',
        url: url,
        colNames: ['Vendor Name', 'CommunityName', 'Primary Acct Nbr', 'BillID'],
        colModel: [
                        { name: 'VendorName', index: 'VendorName', width: 203, align: 'left' },
                        { name: 'CommunityName', index: 'CommunityName', width: 215, align: 'left' },
                        { name: 'PrimaryAcctNumber', index: 'PrimaryAcctNumber', width: 260, align: 'left' },
                        { name: 'BillID', index: 'BillID', hidden: true }
                     ],
        rowNum: 50,
        gridview: true,
        rowList: [10, 20, 30, 50],
        pager: $('#invoicepager'),
        sortname: 'PrimaryAcctNumber',
        viewrecords: true,
        sortorder: "asc",
        rownumbers: false,
        hidegrid: false,
        repeatitems: false,
        recordtext: 'Bill(s) {0} - {1} ',
        cell: "",
        height: "auto",
        loadComplete: function(data) {
           //alert('total is ' + data.responseText);
            if ($invoiceGrid.jqGrid('getGridParam', 'records') == 0) {
                NoRecordsFound();
            } else {
                SetSearchResultsInterface('bills');
            }

            EnableControl($search, true);
            Global.grdInitialized = true;
            $progressbar.hide();
        },
        jsonReader: {

            repeatitems: false,
            id: "RecordID"
        }
    }).navGrid('#invoicepager', { edit: false, add: false, del: false, search: false, refresh: false });

My data is displayed correctly but the pager shows NaN for total pages and total records. Any ideas? Thank you for your help

µBio
  • 10,668
  • 6
  • 38
  • 56
Carlos Lescay
  • 21
  • 1
  • 1
  • 3

3 Answers3

1

It seems that correct format of recordtext should has 3 elements like

recordtext: "View {0} - {1} of {2}"

You use

recordtext: 'Bill(s) {0} - {1} '

You can use

recordtext: 'Bill(s) {0} - {1} of {2}'

instead. But I can not really reproduce your problem also in case of the usage of your original data (see http://www.ok-soft-gmbh.com/jqGrid/PagerProblem.htm which has no problems). Moreover your JSON data should be fixed:

[{JDEVendorNumber"

should be fixed to

[{"JDEVendorNumber"

but probably it's come during posting the data only.

Oleg
  • 220,925
  • 34
  • 403
  • 798
  • Still the same problem if I use 'Bill(s) {0} - {1} of {2}' ,it just displays Bill(s) NaN - NaN of NaN. My JSON response message is properly formatted as I can display the actual rows in the grid. It just the pager shows NaN for all the integer values it expects. Thanks – Carlos Lescay Jul 28 '10 at 21:27
  • Oleg,the JSON data missing " was done by me when pasting the string during my posting. – Carlos Lescay Jul 28 '10 at 21:32
  • You should search your problem in the part of code which you not posted here. Look at http://www.ok-soft-gmbh.com/jqGrid/PagerProblem.htm. This work without any problem. – Oleg Jul 28 '10 at 21:47
  • By the way, it's not an error, but it seems to me that parameter `cell: ""` don't known by jqGrid. – Oleg Jul 28 '10 at 21:52
  • @Oleg: +1 for your explanation with demo. Also I have a small query, if the jqgrid has no rows at some time, it shows `Page 1 of Nan` what is `Nan` here? Here I asked a [question](http://stackoverflow.com/questions/7092924/on-0-row-in-jqgrid-how-can-we-replace-page-1-of-nan-to-something-else) – AabinGunz Aug 17 '11 at 12:39
1

Oleg, by looking at the sample code you sent me, I figured that for the pager to work correctly you need to include grid.formedit.js. In my page I had references only to grid.locale-en.js and jquery.jqGrid.min.js. Apparently that is not enough. I guess, lesson learned for me is to include all the .js libraries that are part of the jqGrid download. Thanks for your help

Carlos Lescay
  • 21
  • 1
  • 1
  • 3
1

Although it does not seem to be the problem here, the loadonce parameter may cause a similar issue (total pages always set to 1). It should be forced to false:

$myGrid.jqGrid({
        datatype: 'json',
        loadonce: false,
        ...
}

The loadonce parameter prevents the client from loading further data after the initial load. As a side effect, the client ignores total and records in the server's response, using only the amount of rows to populate the pager.

In my own code, loadonce must have been defaulted to true, because the pager worked as soon as I explicitly set it to false.

philippe_b
  • 38,730
  • 7
  • 57
  • 59