简体   繁体   中英

Paging is not working in jqgrid, loadonce : false

I want to display json data in jqgrid. I have given loadonce as false, the total records is showing properly in grid pager but the page index is always 1 of 1. any help is appreciated.

Code:

var LoadCDHDetailsGrid = function (backstageViewByVal, bossStoreDate, filterflag, getBackStageDataFromCache, inboundViewType, carrierViewBy, featured) {
    BackstageInboundbuildSearchFilters();
    var mygridwidth = $('.tablegriddiv').width();
    var defaultSort = "expectedDeliveryDate";

    var url = featured ? '/Inbound/RetrieveFeaturedInboundData/' : '/Inbound/RetrieveCDHInboundDetailsData/';
    jQuery("#BackStageGrid").jqGrid({
        url: url,
        postData: { searchfilters: JSON.stringify(BackstageAdvfilters), advf: advf, customsortname: customsortname, customsortorder: customsortorder, filterflag: filterflag, storeDt: bossStoreDate, GetFromCache: getBackStageDataFromCache, packageType: inboundViewType, selectedviewTransfers: backstageViewByVal, carrierView: carrierViewBy },
        datatype: 'json',
        mtype: 'POST',
        colNames: ['Tracking #', 'Carton #', 'Delivery Date', 'Status', 'Status Date', 'Status Time'],
        colModel: [
                            { name: 'bakTrackingNbr', jsonmap: 'trackingLabelNbr', index: 'trackingLabelNbr', width: 170, formatter: commonWorkloadFunctions.trackingHyperlinkFormatter, unformat: commonWorkloadFunctions.trackingnHyperlinkUnFormatter, align: 'center', search: true, classes: "underlineres" },
                            { name: 'bakCarton', jsonmap: 'cartonNumber', index: 'cartonNumber', width: 145, align: 'center', search: true, formatter: commonWorkloadFunctions.cdhCartonHyperlinkFormatter, unformat: commonWorkloadFunctions.cartonHyperlinkUnFormatter, classes: "underlineres" },
                            //Added for SSW2- 292
                            { name: 'bakExpectedDelDate', jsonmap: 'expectedDeliveryDateTime', index: 'expectedDeliveryDate', width: 125, align: 'center', sorttype: 'date', formatter: 'date', formatoptions: { srcformat: "ISO8601Long", newformat: "m/d/Y" }, search: true },
                             {
                                 name: 'bakStatus', jsonmap: 'status', index: 'Status', width: 150, align: 'center', formatter: 'select',
                                 edittype: 'select', editoptions: {
                                     value: workloadGridDropdownColumnsList.statusListBackstage(),
                                     defaultValue: 'ALL',
                                     multiple: true,
                                     width: '200'
                                 },
                                 stype: 'select', searchoptions: {
                                     sopt: ['eq', 'ne'],
                                     value: workloadGridDropdownColumnsList.statusListInBoundBackstage(),
                                     attr: { multiple: 'multiple', size: 5 },
                                     dataInit: dataInitMultiselect
                                 }
                             },

                            { name: 'bakStatusDate', jsonmap: 'statusDate', index: 'StatusDate', width: 100, align: 'center', search: true },
                            { name: 'bakStatusTime', jsonmap: 'statusTime', index: 'StatusTime', width: 80, align: 'center', search: false },
        ],

        pager: '#BackStageGridPager',
        rowNum: 30,
        width: mygridwidth,
        gridview: true,
        ignoreCase: true,
        cmTemplate: { resizable: false },
        sortname: 'trackingLabelNbr',
        sortname: defaultSort,
        viewrecords: true,
        sortorder: 'asc',
        sortable: false,
        scrollable: true,
        loadonce: false,
        shrinkToFit: true,
        onSelectRow: function (rowid, status, e) {
            backstageGridBuiltinFunctions.backstageGridOnSelectRow(rowid, status, e);
        },
        beforeRequest: function () {
            if (toolbarBackStatusSel.length == 0) {
                $("input:checkbox[name=multiselect_gs_bakStatus]:checked").each(function () {
                    toolbarBackStatusSel.push($(this).attr('value'));
                    bakstatusValue += $(this).attr('value') + ",";
                });

                if (bakstatusValue.length >= 1 && advfilters !== '') {
                    for (var i = 0; i < advfilters.length; i++) {
                        if (advfilters[i].SearchingName == 'Status')
                            advfilters.splice(i, 1);
                    }
                    advfilters.push({ SearchingName: "Status", SearchingValue: (bakstatusValue.replace(/,\s*$/, '')) });
                }
            }
            jQuery("#BackStageGrid").jqGrid('setGridParam', { postData: { searchfilters: JSON.stringify(advfilters), advf: advf, customsortname: customsortname, customsortorder: customsortorder, filterflag: filterflag, storeDt: bossStoreDate, GetFromCache: getBackStageDataFromCache, packageType: inboundViewType, selectedviewTransfers: backstageViewByVal, carrierView: carrierViewBy } });

            if (typeof $("#gs_bakTrackingNbr").val() !== 'undefined') {
                baktrackingNoValue = $("#gs_bakTrackingNbr").val();
            }
            if (typeof $("#gs_bakCarton").val() !== 'undefined') {
                bakcartonNoValue = $("#gs_bakCarton").val();
            }
            if (typeof $("#gs_bakExpectedDelDate").val() !== 'undefined') {
                bakexpectedDelDateValue = $("#gs_bakExpectedDelDate").val();
            }

            if (typeof $("#gs_bakPackageType").val() !== 'undefined') {
                bakpackageTypeValue = $("#gs_bakPackageType").val();
            }
            if (typeof $("#gs_bakStatusDate").val() !== 'undefined') {
                bakstatusDateValue = $("#gs_bakStatusDate").val();
            }
            if (typeof $("#gs_bakStatusTime").val() !== 'undefined') {
                bakstatusTimeValue = $("#gs_bakStatusTime").val();
            }

        },
        onPaging: function () {
            filterflag = false;
            getBackStageDataFromCache = true;
        },
        loadComplete: function (data) {
            backstageGridBuiltinFunctions.backstageGridViewLoadComplete(data);

        },
        loadError: function (xhr, status, error) {
            filterflag = true;
            getBackStageDataFromCache = false;
            commonFunctions.spmDialogueAlert("Data service connectivity error.");
            commonWorkloadFunctions.hideLoadingMessage();
        },
        height: "400",
        timeout: 600000
    }).trigger("reloadGrid");

    var theGrid = jQuery("#BackStageGrid");
    theGrid.jqGrid('navGrid', '#BackStageGridPager', { refreshstate: 'current', edit: false, refresh: false, search: false, del: false, add: false });
    theGrid.jqGrid('filterToolbar', { stringResult: true, searchOnEnter: true, defaultSearch: myDefaultSearch, beforeSearch: BackStageInboundBeforeSearchHandler });
};

I have tried using loadonce as true. then the pagination is working, but when searching a value the grid is blank. no records is returning. my data is returning from a web service. the is no issue with the data.

I was able to resolve the issue by sending record count, page index along with data. which I was not sending previously.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM