admin管理员组

文章数量:1404561

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

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

Share Improve this question edited Jul 28, 2010 at 18:10 µBio 10.8k6 gold badges40 silver badges56 bronze badges asked Jul 28, 2010 at 18:06 Carlos LescayCarlos Lescay 211 gold badge1 silver badge3 bronze badges 1
  • Try setting those names in your jsonReader – Craig Stuntz Commented Jul 28, 2010 at 18:44
Add a ment  | 

3 Answers 3

Reset to default 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./jqGrid/PagerProblem.htm which has no problems). Moreover your JSON data should be fixed:

[{JDEVendorNumber"

should be fixed to

[{"JDEVendorNumber"

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

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

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.

本文标签: javascriptJqGrid pager problemTotal pages and records does not display correctlyStack Overflow