views:

63

answers:

2

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

A: 

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
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
Oleg,the JSON data missing " was done by me when pasting the string during my posting.
Carlos Lescay
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
By the way, it's not an error, but it seems to me that parameter `cell: ""` don't known by jqGrid.
Oleg
+1  A: 

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