6

我需要根据 jqGrid 中的排序顺序来操作本地数组,因为我正在使用行索引来修改本地数据数组,当网格按备用列排序时,该数组会塞满。我可以看到 jqGrid 有一个onSortCol事件在单击标题后但在排序之前触发,但在排序之后没有调用。我在文档中看不到任何可以挂钩的内容?有任何想法吗?

编辑:添加一些代码

这是我的 jqGrid 代码的全部内容:

$list.jqGrid({
    formatter: {
        currency: { decimalSeparator: ".", thousandsSeparator: ",", decimalPlaces: 2, prefix: "$", suffix: "", defaultValue: '0.00' }
    },
    datatype: "local",
    colNames: ['Id',
    '<img src=\'Images/Global/alert.gif\' alt=\'Set As Favourite\' title=\'Set As Favourite\' />',
    'Delivery #', 'Pickup', 'From', 'Deliver', 'To', 'Destination',
    'Carrier', 'Vehicle', 'Load', 'IsSelected', 'Status','PickupResourceId','DeliverResourceId'],
    colModel: [
        { name: 'Id', index: 'ConsignmentId', width: 65, hidden: true },
        { name: 'Favourite', index: 'Favourite', width: 18, align: 'center' },
        { name: 'DeliveryNumber', index: 'DeliveryNumber', width: 65 },
        { name: 'Pickup', index: 'Pickup', width: 60, align: 'left', sorttype: 'date', datefmt: 'd/M/Y' },
        { name: 'From', index: 'From', width: 85, formatter: 'rowHeight' },
        { name: 'Deliver', index: 'Deliver', width: 60, align: 'left', sorttype: 'date', datefmt: 'd/M/Y' },
        { name: 'To', index: 'To', width: 85, align: 'left', formatter: 'rowHeight' },
        { name: 'Destination', index: 'Destination', align: 'left' },
        { name: 'Carrier', index: 'Carrier', width: 65, align: 'left' },
        { name: 'Vehicle', index: 'Vehicle', width: 65, align: 'left' },
        { name: 'Load', index: 'Load', align: 'left', formatter: 'rowHeight' },
        { name: 'IsSelected', index: 'IsSelected', width: 5, hidden: true },
        { name: 'Status', index: 'Status', width: 5, hidden: true },
        { name: 'PickupResourceId', index: 'PickupResourceId', hidden:true},
        { name: 'DeliverResourceId', index: 'DeliverResourceId', hidden:true}
    ],

    altRows:true,
    altclass:'myAltRowClass',

    width: gridWidth,
    height: "100%",
    loadonce: true,
    gridview: true,
    page: $listpg.val(),
    cellLayout: 7,

    pager: '#dispatch-footer',
    rowNum: 10,
    viewrecords: true,
    rowList: [10, 20, 30],
    sortname: 'invid',
    sortorder: 'desc',
    multiselect: true,
    onPaging: function (pgButton) {
        $listpg.val($list.getGridParam('page'));
    },
    onCellSelect: function (rowId, colId, cellContent, e) {
        if (colId != 0 ) { //&& colId != 2
            hideMsgs();
            $list.jqGrid('resetSelection');
            $list.jqGrid('setSelection', rowId);

            rowIdx = ($(this).getGridParam('rowNum') * ($(this).getGridParam('page') - 1)) + (rowId - 1);
            rowWasRemoved = false;

            var cons = $list.jqGrid('getCell', rowId, 1);
            loadDelivery({});
            eCargo.api.get('v1.00/delivery/' + cons, 0, loadDelivery,
                funcError('Unable to load Delivery', 5000, $jobEdit));
            $jobEdit.dialog('open');
            $jobEdit.block();
        }
        /*if (colId == 2) {
            var newImage = $list.getCell(rowId, colId) == '' ? exclIcon : '';
            $list.setCell(rowId, colId, newImage, "", "");
            $list.jqGrid('resetSelection', rowId);
        }*/
    },
    onSelectRow: function (rowid, status) {
        var ret = $list.jqGrid('getRowData', rowid);
        if (status) {
            if (selectedIds.indexOf(ret.Id) == -1)
                selectedIds.push(ret.Id);
        }
        else {
            selectedIds.splice(selectedIds.indexOf(ret.Id), 1);
        }
        $gIds.val(selectedIds.join('|'));
    },
    loadComplete: function () {
        var ids = $list.getDataIDs();
        for (var i = 0; i < ids.length; i++) {
            $list.setRowData(ids[i], false, { height: 40 });
        }
        $('#jqgh_cb').css('text-align', 'center');
    },
    gridComplete: function () {
        var ids = $list.getDataIDs();
        for (var i = 0; i < ids.length; i++) {
            //if late
            if (dates.compare(
                    new Date($list.jqGrid('getCell', ids[i], 'Deliver')).addDays(1),
                    $list.jqGrid('getCell', ids[i], 'Deliver'))
                && $list.jqGrid('getCell', ids[i], 'Status') !== 'DELIVERED') {
                //$list.find("#" + ids[i]).css({ color: 'red' });
            }
            if ($gIds.val() != '') {
                var ret = $list.jqGrid('getRowData', ids[i]);
                if (selectedIds.indexOf(ret.Id) > -1)
                    $list.jqGrid('setSelection', ids[i]);
            }
        }
        $('#jqgh_cb').css('text-align', 'center');
    },
    onSelectAll: function (aRowids, status) {
        hideMsgs();
        var ids = $list.jqGrid('getDataIDs');
        for (var i = 0; i < ids.length; i++) {
            var ret = $list.jqGrid('getRowData', ids[i]);
            //setIsSelected(ret.InvoiceId, status);
            //$list.jqGrid('setCell', ids[i], 'IsSelected', status);
            if (status) {
                if ($.inArray(ret.Id, selectedIds) == -1)
                    selectedIds.push(ret.Id);
            }
            else
                selectedIds.splice(selectedIds.indexOf(ret.Id), 1);
        }
        $gIds.val(selectedIds.join('|'));
    }
})
.navGrid('#dispatch-footer', { edit: false, add: false, del: false, search: false });

这是将数据加载到网格中的位置以及 json 的格式化函数:

var consLoader = new Loader({
    $grid: $list,
    URL: 'v1.00/delivery',
    count: 20,
    Error: funcError('Unable to retrieve search consignments.', 5000, $(this)),
    SearchNotFound: funcSuccess('No consignments found.', 5000),
    GridBound: function () {
        this.$grid.jqGrid('setGridParam', { page: $listpg.val() }).trigger("reloadGrid");
    },
    DetailsSuccess: function (rtn) {
        var ldr = this;
        ldr.bindGrid = true;
        $.EO_each(rtn, function (i, e) {
            ldr.list.push(formatConsignment(e));
        });
    }
});

function formatConsignment(cons) {
    var icon = '';
    if (cons.ReturnLiability)
        icon = retnIcon;
    if (cons.ConsignmentAttrs && cons.ConsignmentAttrs.match('PRIORITY'))
        icon = exclIcon; // exclIcon is favourite
    return {
        $raw: cons,
        Id: cons.ConsignmentId,
        Favourite: icon,
        DeliveryNumber: cons.ConsignmentNbr,
        From: cons.PickupResourceName.toProperCase(),
        Pickup: vortalDateTime(cons.PickupPlannedDepartureDate),
        To: cons.DeliverResourceName.toProperCase(),
        Deliver: vortalDateTime(cons.DeliverPlannedArrivalDate),
        Destination: eCargoAddress(cons.DeliverToAddress).toProperCase(),
        Carrier: cons.CarrierResourceName.toProperCase(),
        Vehicle: cons.Vehicle == undefined ? '' : cons.Vehicle.toProperCase(),
        Load: cons.Description.toProperCase(),
        Comments: cons.Comments ? cons.Comments : '',
        PickupResourceId: cons.PickupResourceId,
        DeliverResourceId: cons.DeliverResourceId,
        Status: cons.Status,
        IsSelected: false
    };
}

这是三个记录的一些 json。

{"_type":"Consignments","_":[{"_type":"Consignment","Deleted":"N","NoOrder":"N","ConsignmentId":4166306,"ObjectTypeName":"CONSIGNMENT","ReadTimestamp":"2012-03-16 19:34:17.113","ConsignmentAuths":"ASSIGN_VEHICLE|CHANGE|CREATE_LEGS|DEASSIGN_VEHICLE|DELIVER|DISPATCH|MAKE_PRIORITY|NOTIFY|REMOVE_PRIORITY|SUBCONTRACT|VIEW|","ConsignmentAttrs":"JOBTYPE=Grocery|","Description":"Palleted: 750 KGS, 10.52 M3, 224 Cartons, 4 PAL, 4 Lifts","ConsignmentNbr":"0081604437","PickupActualDepartureDate":"16 Mar 2012 19:33:30","Status":"DISPATCHED","NextAction":"Confirm Delivery","Vehicle":"cfd","DeliverResourceId":23760,"CarrierResourceId":2255,"PickupResourceId":7320,"OwnerResourceId":7320,"DeliverResourceName":"PAK N SAVE GLEN INNES","CarrierResourceName":"Cardinal Logistics Ltd","PickupResourceName":"Griffins Foods - DC","OwnerResourceName":"Griffins Foods - DC","CarrierResourceShortName":"Cardinal Logistics Ltd","DeliverToAddress":{"_type":"DeliverToAddress","Address":{"_type":"Address","Street":"182 APIRANA AVENUE","Suburb":"GLEN INNES","City":"AUCKLAND","Country":"NZ","RegionId":478,"RegionName":"AKE"}},"PickupAddress":{"_type":"PickupAddress","Address":{"_type":"Address","Street":"113-3 Savill Drive","Suburb":"Otahuhu","City":"Auckland","Country":"New Zealand","RegionId":400,"RegionName":"South Akld"}},"PickupPlannedArrivalDate":{"_type":"PickupPlannedArrivalDate","VortalDateTime":{"_type":"VortalDateTime","DateValue":"19 Mar 2012","TimeZone":"UTC@@plus;12"}},"PickupPlannedDepartureDate":{"_type":"PickupPlannedDepartureDate","VortalDateTime":{"_type":"VortalDateTime","DateValue":"19 Mar 2012","TimeZone":"UTC@@plus;12"}},"DeliverPlannedArrivalDate":{"_type":"DeliverPlannedArrivalDate","VortalDateTime":{"_type":"VortalDateTime","DateValue":"19 Mar 2012","TimeValue":"99:99"}},"DeliverPlannedDepartureDate":{"_type":"DeliverPlannedDepartureDate","VortalDateTime":{"_type":"VortalDateTime","DateValue":"19 Mar 2012"}},"ConsignmentItems":{"_type":"ConsignmentItems","_":[{"_type":"ConsignmentItemHeader","Deleted":"N","ConsignmentItemId":94540510,"ConsignmentItem":{"_type":"ConsignmentItem","Deleted":"N","Item":{"_type":"Item","ItemId":97277,"ItemDesc":"Palleted","Weight":7500000,"WeightUomCode":"Kilograms","WeightUomId":594,"Volume":105200,"VolumeUomCode":"m³","VolumeUomId":615,"Qty1":2240000,"Qty1UomCode":"Cartons","Qty1UomId":766,"Qty2":40000,"Qty2UomCode":"Pallet","Qty2UomId":648,"Qty3":40000,"Qty3UomCode":"Lifts","Qty3UomId":733}}}]},"ConsignmentPartners":{"_type":"ConsignmentPartners","_":[{"_type":"ConsignmentPartner","Deleted":"N","PartnerId":45203410,"RoleId":5,"RoleCode":"OWNER","RoleName":"Owner","PartnerName":"Griffins Foods - DC","PartnerResourceId":7320,"PartnerAddress":{"_type":"PartnerAddress","Address":{"_type":"Address","Street":"113-3 Savill Drive","Suburb":"Otahuhu","City":"Auckland","Country":"NZ","RegionId":400,"RegionName":"South Akld"}}},{"_type":"ConsignmentPartner","Deleted":"N","PartnerId":45203411,"RoleId":1,"RoleCode":"CARRIER","RoleName":"Carrier","PartnerName":"Cardinal Logistics Ltd","PartnerResourceId":2255,"PartnerAddress":{"_type":"PartnerAddress","Address":{"_type":"Address","Street":"71-77 Westney Rd","Suburb":"Mangere","City":"Auckland","Country":"NZ","RegionId":261,"RegionName":"Auckland South"}}},{"_type":"ConsignmentPartner","Deleted":"N","PartnerId":45203412,"RoleId":6,"RoleCode":"PICKUP_POINT","RoleName":"Outwards Goods","PartnerName":"Griffins Foods - DC","PartnerResourceId":7320,"PartnerAddress":{"_type":"PartnerAddress","Address":{"_type":"Address","Street":"113-3 Savill Drive","Suburb":"Otahuhu","City":"Auckland","Country":"NZ","RegionId":400,"RegionName":"South Akld"}}},{"_type":"ConsignmentPartner","Deleted":"N","PartnerId":45203413,"RoleId":4,"RoleCode":"MGR_SPECTATOR_OUT","RoleName":"Manager Spectator Outwards Goods","PartnerName":"Griffins Foods Ltd","PartnerResourceId":3329,"PartnerAddress":{"_type":"PartnerAddress","Address":{"_type":"Address","Street":"Hunua Road","Suburb":"Papakura","PostCode":"1733","City":"Auckland","Country":"NZ","RegionId":261,"RegionName":"Auckland South"}}},{"_type":"ConsignmentPartner","Deleted":"N","PartnerId":45203414,"RoleId":11,"RoleCode":"DIVISION_MANAGER_OUT","RoleName":"Division Manager Outwards","PartnerName":"Griffins Foods Ltd","PartnerResourceId":3329,"PartnerAddress":{"_type":"PartnerAddress","Address":{"_type":"Address","Street":"Hunua Road","Suburb":"Papakura","PostCode":"1733","City":"Auckland","Country":"NZ","RegionId":261,"RegionName":"Auckland South"}}},{"_type":"ConsignmentPartner","Deleted":"N","PartnerId":45203415,"RoleId":3,"RoleCode":"DELIVERY_POINT","RoleName":"Inwards Goods","PartnerName":"Glen Innes Pak N Save","PartnerResourceId":23760,"PartnerAddress":{"_type":"PartnerAddress","Address":{"_type":"Address","Street":"182 Apirana Avenue","City":"Auckland","Country":"NZ","RegionId":2,"RegionName":"New Zealand"}}}]},"AutoGenerateItems":"N","OriginatingOrder":{"_type":"OriginatingOrder","Deleted":"N","OrderId":8944037,"SalesOrderNumber":"3977545","PurchaseOrderNumber":"3977545","OrderType":"order","Description":"Palleted: 515.2 KGS, 10.12 M3, 224 Cartons, 6 PAL, 6 Lifts","SourceSystemReference":"0081604437","SourceSystem":"GRIFFINS"},"PickupCarrierId":2255,"PickupCarrierName":"Cardinal Logistics Ltd","L1_ResidualSplitLoad":{"_type":"L1_ResidualSplitLoad","Deleted":"N","NoOrder":"N","AutoGenerateItems":"N"}},{"_type":"Consignment","Deleted":"N","NoOrder":"N","ConsignmentId":4167062,"ObjectTypeName":"CONSIGNMENT","ReadTimestamp":"2012-03-16 18:03:33.407","ConsignmentAuths":"ASSIGN_VEHICLE|CHANGE|CREATE_LEGS|DEASSIGN_VEHICLE|DELIVER|DISPATCH|MAKE_PRIORITY|NOTIFY|REMOVE_PRIORITY|SUBCONTRACT|VIEW|","ConsignmentAttrs":"JOBTYPE=Grocery|","Description":"Palleted: 153.91 KGS, 1.0124 M3, 54 Cartons, 1 PAL, 1 Lifts","ConsignmentNbr":"0081604564","PickupActualDepartureDate":"16 Mar 2012 18:03:28","Status":"DISPATCHED","NextAction":"Confirm Delivery","Vehicle":"cfd","DeliverResourceId":29305,"CarrierResourceId":2255,"PickupResourceId":7320,"OwnerResourceId":7320,"DeliverResourceName":"METRO NEW WORLD QUEEN STREET 616672","CarrierResourceName":"Cardinal Logistics Ltd","PickupResourceName":"Griffins Foods - DC","OwnerResourceName":"Griffins Foods - DC","CarrierResourceShortName":"Cardinal Logistics Ltd","DeliverToAddress":{"_type":"DeliverToAddress","Address":{"_type":"Address","Street":"125 QUEEN STREET","Suburb":"AUCKLAND CENTRAL","City":"AUCKLAND","Country":"NZ","RegionId":454,"RegionName":"ACM"}},"PickupAddress":{"_type":"PickupAddress","Address":{"_type":"Address","Street":"113-3 Savill Drive","Suburb":"Otahuhu","City":"Auckland","Country":"New Zealand","RegionId":400,"RegionName":"South Akld"}},"PickupPlannedArrivalDate":{"_type":"PickupPlannedArrivalDate","VortalDateTime":{"_type":"VortalDateTime","DateValue":"19 Mar 2012","TimeZone":"UTC@@plus;12"}},"PickupPlannedDepartureDate":{"_type":"PickupPlannedDepartureDate","VortalDateTime":{"_type":"VortalDateTime","DateValue":"19 Mar 2012","TimeZone":"UTC@@plus;12"}},"DeliverPlannedArrivalDate":{"_type":"DeliverPlannedArrivalDate","VortalDateTime":{"_type":"VortalDateTime","DateValue":"19 Mar 2012","TimeValue":"08:00"}},"DeliverPlannedDepartureDate":{"_type":"DeliverPlannedDepartureDate","VortalDateTime":{"_type":"VortalDateTime","DateValue":"19 Mar 2012","TimeValue":"08:00"}},"ConsignmentItems":{"_type":"ConsignmentItems","_":[{"_type":"ConsignmentItemHeader","Deleted":"N","ConsignmentItemId":94557821,"ConsignmentItem":{"_type":"ConsignmentItem","Deleted":"N","Item":{"_type":"Item","ItemId":97277,"ItemDesc":"Palleted","Weight":1539100,"WeightUomCode":"Kilograms","WeightUomId":594,"Volume":10124,"VolumeUomCode":"m³","VolumeUomId":615,"Qty1":540000,"Qty1UomCode":"Cartons","Qty1UomId":766,"Qty2":10000,"Qty2UomCode":"Pallet","Qty2UomId":648,"Qty3":10000,"Qty3UomCode":"Lifts","Qty3UomId":733}}}]},"ConsignmentPartners":{"_type":"ConsignmentPartners","_":[{"_type":"ConsignmentPartner","Deleted":"N","PartnerId":45200146,"RoleId":5,"RoleCode":"OWNER","RoleName":"Owner","PartnerName":"Griffins Foods - DC","PartnerResourceId":7320,"PartnerAddress":{"_type":"PartnerAddress","Address":{"_type":"Address","Street":"113-3 Savill Drive","Suburb":"Otahuhu","City":"Auckland","Country":"NZ","RegionId":400,"RegionName":"South Akld"}}},{"_type":"ConsignmentPartner","Deleted":"N","PartnerId":45200147,"RoleId":1,"RoleCode":"CARRIER","RoleName":"Carrier","PartnerName":"Cardinal Logistics Ltd","PartnerResourceId":2255,"PartnerAddress":{"_type":"PartnerAddress","Address":{"_type":"Address","Street":"71-77 Westney Rd","Suburb":"Mangere","City":"Auckland","Country":"NZ","RegionId":261,"RegionName":"Auckland South"}}},{"_type":"ConsignmentPartner","Deleted":"N","PartnerId":45200148,"RoleId":6,"RoleCode":"PICKUP_POINT","RoleName":"Outwards Goods","PartnerName":"Griffins Foods - DC","PartnerResourceId":7320,"PartnerAddress":{"_type":"PartnerAddress","Address":{"_type":"Address","Street":"113-3 Savill Drive","Suburb":"Otahuhu","City":"Auckland","Country":"NZ","RegionId":400,"RegionName":"South Akld"}}},{"_type":"ConsignmentPartner","Deleted":"N","PartnerId":45200149,"RoleId":4,"RoleCode":"MGR_SPECTATOR_OUT","RoleName":"Manager Spectator Outwards Goods","PartnerName":"Griffins Foods Ltd","PartnerResourceId":3329,"PartnerAddress":{"_type":"PartnerAddress","Address":{"_type":"Address","Street":"Hunua Road","Suburb":"Papakura","PostCode":"1733","City":"Auckland","Country":"NZ","RegionId":261,"RegionName":"Auckland South"}}},{"_type":"ConsignmentPartner","Deleted":"N","PartnerId":45200150,"RoleId":11,"RoleCode":"DIVISION_MANAGER_OUT","RoleName":"Division Manager Outwards","PartnerName":"Griffins Foods Ltd","PartnerResourceId":3329,"PartnerAddress":{"_type":"PartnerAddress","Address":{"_type":"Address","Street":"Hunua Road","Suburb":"Papakura","PostCode":"1733","City":"Auckland","Country":"NZ","RegionId":261,"RegionName":"Auckland South"}}},{"_type":"ConsignmentPartner","Deleted":"N","PartnerId":45200151,"RoleId":3,"RoleCode":"DELIVERY_POINT","RoleName":"Inwards Goods","PartnerName":"METRO NEW WORLD QUEEN STREET 616672","PartnerResourceId":29305,"PartnerAddress":{"_type":"PartnerAddress","Address":{"_type":"Address","Street":"125 QUEEN STREET","Suburb":"AUCKLAND CENTRAL","City":"AUCKLAND","Country":"NZ","RegionId":454,"RegionName":"ACM"}}}]},"AutoGenerateItems":"N","OriginatingOrder":{"_type":"OriginatingOrder","Deleted":"N","OrderId":8945604,"SalesOrderNumber":"3978056","PurchaseOrderNumber":"3978056","OrderType":"order","Description":"Palleted: 136.91 KGS, 1.047 M3, 64 Cartons, 1 PAL, 1 Lifts","SourceSystemReference":"0081604564","SourceSystem":"GRIFFINS"},"PickupCarrierId":2255,"PickupCarrierName":"Cardinal Logistics Ltd","L1_ResidualSplitLoad":{"_type":"L1_ResidualSplitLoad","Deleted":"N","NoOrder":"N","AutoGenerateItems":"N"}},{"_type":"Consignment","Deleted":"N","NoOrder":"N","ConsignmentId":4167304,"ObjectTypeName":"CONSIGNMENT","ReadTimestamp":"2012-03-16 15:39:10.247","ConsignmentAuths":"ASSIGN_VEHICLE|CHANGE|CREATE_LEGS|DEASSIGN_VEHICLE|DELIVER|DISPATCH|MAKE_PRIORITY|NOTIFY|REMOVE_PRIORITY|SUBCONTRACT|VIEW|","Description":"Palleted Goods: 1765 KG, 5.81 M3, 4 CARTONS, 4 CHEP","ConsignmentNbr":"PZC-01298521","PickupActualArrivalDate":"16 Mar 2012 00:00:00","PickupActualDepartureDate":"16 Mar 2012 00:00:00","ProtectionType":"Ambient","Status":"DISPATCHED","NextAction":"Confirm Delivery","Vehicle":"cfd","DeliverResourceId":23773,"CarrierResourceId":23103,"PickupResourceId":29069,"OwnerResourceId":29061,"DeliverResourceName":"Mt Albert Pak N Save","CarrierResourceName":"Route and Retail","PickupResourceName":"PZ Cussons Auckland","OwnerResourceName":"PZ Cussons (NZ) Pty Ltd","DeliverToAddress":{"_type":"DeliverToAddress","Address":{"_type":"Address","Street":"1167-1177 New North Road","City":"MT ALBERT","RegionId":2,"RegionName":"New Zealand"}},"PickupAddress":{"_type":"PickupAddress","Address":{"_type":"Address","Street":"EX Mondiale AKL","Suburb":"78 Montogomerie Road, Airport Oaks","City":"Auckland","RegionId":284,"RegionName":"Auckland"}},"PickupPlannedArrivalDate":{"_type":"PickupPlannedArrivalDate","VortalDateTime":{"_type":"VortalDateTime","DateValue":"16 Mar 2012","TimeValue":"14:30"}},"PickupPlannedDepartureDate":{"_type":"PickupPlannedDepartureDate","VortalDateTime":{"_type":"VortalDateTime","DateValue":"16 Mar 2012","TimeValue":"14:30"}},"DeliverPlannedArrivalDate":{"_type":"DeliverPlannedArrivalDate","VortalDateTime":{"_type":"VortalDateTime","DateValue":"19 Mar 2012","TimeValue":"17:00"}},"DeliverPlannedDepartureDate":{"_type":"DeliverPlannedDepartureDate","VortalDateTime":{"_type":"VortalDateTime","DateValue":"19 Mar 2012","TimeValue":"17:00"}},"ConsignmentItems":{"_type":"ConsignmentItems","_":[{"_type":"ConsignmentItemHeader","Deleted":"N","ConsignmentItemId":94550141,"ConsignmentItem":{"_type":"ConsignmentItem","Deleted":"N","Item":{"_type":"Item","ItemId":2321559,"ItemDesc":"Palleted Goods","Weight":17650000,"WeightUomCode":"Kilogram","WeightUomId":593,"Volume":58100,"VolumeUomCode":"m³","VolumeUomId":615,"Qty1":40000,"Qty1UomCode":"Cartons","Qty1UomId":766,"Qty2":40000,"Qty2UomCode":"Chep","Qty2UomId":723}}}]},"ConsignmentPartners":{"_type":"ConsignmentPartners","_":[{"_type":"ConsignmentPartner","Deleted":"N","PartnerId":45190257,"RoleId":6,"RoleCode":"PICKUP_POINT","RoleName":"Outwards Goods","PartnerName":"PZ Cussons Auckland","PartnerResourceId":29069,"PartnerAddress":{"_type":"PartnerAddress","Address":{"_type":"Address","Street":"EX Mondiale AKL","Suburb":"78 Montogomerie Road, Airport Oaks","City":"Auckland","Country":"NZ","RegionId":284,"RegionName":"Auckland"}}},{"_type":"ConsignmentPartner","Deleted":"N","PartnerId":45190258,"RoleId":11,"RoleCode":"DIVISION_MANAGER_OUT","RoleName":"Division Manager Outwards","PartnerName":"Foodstuffs Inbound","PartnerResourceId":23095,"PartnerAddress":{"_type":"PartnerAddress","Address":{"_type":"Address","Street":"Kiln Street","Suburb":"Silversteam","City":"Wellington","Country":"NZ","RegionId":2,"RegionName":"New Zealand"}}},{"_type":"ConsignmentPartner","Deleted":"N","PartnerId":45190259,"RoleId":11,"RoleCode":"DIVISION_MANAGER_OUT","RoleName":"Division Manager Outwards","PartnerName":"FIN Account Managers","PartnerResourceId":27078,"PartnerAddress":{"_type":"PartnerAddress","Address":{"_type":"Address","Country":"NZ","RegionId":2,"RegionName":"New Zealand"}}},{"_type":"ConsignmentPartner","Deleted":"N","PartnerId":45190260,"RoleId":3,"RoleCode":"DELIVERY_POINT","RoleName":"Inwards Goods","PartnerName":"Mt Albert Pak N Save","PartnerResourceId":23773,"PartnerAddress":{"_type":"PartnerAddress","Address":{"_type":"Address","Street":"1167-1177 New North Road","Suburb":"Mt Albert","City":"Auckland","Country":"NZ","RegionId":2,"RegionName":"New Zealand"}}},{"_type":"ConsignmentPartner","Deleted":"N","PartnerId":45190261,"RoleId":17,"RoleCode":"LOGISTICS_PROV","RoleName":"Logistics Provider","PartnerName":"Foodstuffs Inbound","PartnerResourceId":23095,"PartnerAddress":{"_type":"PartnerAddress","Address":{"_type":"Address","Street":"Kiln Street","Suburb":"Silversteam","City":"Wellington","Country":"NZ","RegionId":2,"RegionName":"New Zealand"}}},{"_type":"ConsignmentPartner","Deleted":"N","PartnerId":45190262,"RoleId":5,"RoleCode":"OWNER","RoleName":"Owner","PartnerName":"PZ Cussons (NZ) Pty Ltd","PartnerResourceId":29061,"PartnerAddress":{"_type":"PartnerAddress","Address":{"_type":"Address","Street":"Building C4","Suburb":"Pacific Road, Mt Wellington","City":"Auckland","Country":"NZ","RegionId":2,"RegionName":"New Zealand"}}},{"_type":"ConsignmentPartner","Deleted":"N","PartnerId":45190263,"RoleId":1,"RoleCode":"CARRIER","RoleName":"Carrier","PartnerName":"Route and Retail","PartnerResourceId":23103,"PartnerAddress":{"_type":"PartnerAddress","Address":{"_type":"Address","Street":"3 Roma Road, Mt Roskill","Suburb":"DX Box CX 15021","City":"Auckland","Country":"NZ","RegionId":2,"RegionName":"New Zealand"}}},{"_type":"ConsignmentPartner","Deleted":"N","PartnerId":45190264,"RoleId":2,"RoleCode":"CARRIER_SPECTATOR","RoleName":"Carrier Spectator","PartnerName":"Foodstuffs Inbound","PartnerResourceId":23095,"PartnerAddress":{"_type":"PartnerAddress","Address":{"_type":"Address","Street":"Kiln Street","Suburb":"Silversteam","City":"Wellington","Country":"NZ","RegionId":2,"RegionName":"New Zealand"}}},{"_type":"ConsignmentPartner","Deleted":"N","PartnerId":45190265,"RoleId":1,"RoleCode":"CARRIER","RoleName":"Carrier","PartnerName":"Cardinal Logistics Ltd","PartnerResourceId":2255,"PartnerAddress":{"_type":"PartnerAddress","Address":{"_type":"Address","Street":"71-77 Westney Rd","Suburb":"Mangere","City":"Auckland","Country":"NZ","RegionId":261,"RegionName":"Auckland South"}}}]},"AutoGenerateItems":"N","OriginatingOrder":{"_type":"OriginatingOrder","Deleted":"N","OrderId":8946047,"PurchaseOrderNumber":"138807","OrderType":"order","Description":"Foodstuffs Consignment","SourceSystem":"CMP"},"PickupCarrierId":2255,"PickupCarrierName":"Cardinal Logistics Ltd","L1_ResidualSplitLoad":{"_type":"L1_ResidualSplitLoad","Deleted":"N","NoOrder":"N","AutoGenerateItems":"N"}}]}

注意我升级到 jqGrid 4.3.2 但没有效果。让我知道发布加载程序代码是否会有所帮助,但这实际上只是调用我们的 api 来拉回 json 并设置一些属性以将数据绑定到网格/处理错误。

4

2 回答 2

4

您可以将loadComplete其用作“afterSort”事件。这真是进行此类行动的好地方。如果需要,您可以在 event 内部设置一些变量onSortCol并对其进行测试,然后在loadComplete. 这样,您将能够区分由于更改排序顺序而重新加载网格和由于其他原因重新加载网格。

顺便说一句,jqGrid 有内部行索引。是_index。例如,查看答案以获取更多信息。此外,您可以使用jqGrid 的getLocalRow方法,它可以让您引用databy rowid 中的项目。如果需要,您可以修改getLocalRow方法返回的对象的任何属性。

更新:从您发送给我的电子邮件中,我知道您在从服务器加载数据后data针对方法设置了 jqGrid 的参数。setGridParam在这种情况下,您必须_index通过调用refreshIndex方法来重建另一个内部 jqGrid 参数。方法是table DOM的expando,对应的调用如下$("#grid")[0].refreshIndex()

在大多数情况下,_index它将自动重建,但在您的情况下,它是未定义的。所以我认为手动重建_index使用refreshIndex方法应该可以解决你的问题。

我建议您_index在设置网格之后data和重新加载网格之前.trigger("reloadGrid")使用.

您可以在答案中找到有关refreshIndex方法用法的更多信息。

于 2012-05-08T21:34:35.443 回答
1

它使用包含排序停止事件的 jQuery-UI 可排序。你可以用它来听,

$('#jqgrid').on( "sortstop", function(event, ui) {
  ...
});

我没有对此进行测试,所以我不确定您需要听网格中的哪个元素。

于 2012-05-08T21:23:00.270 回答