jqGrid有一个afterSort事件或类似的东西吗?

时间:2012-05-08 21:13:32

标签: jquery jqgrid

我需要根据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但没有效果。让我知道如果发布Loader代码会有所帮助,但它实际上只是调用我们的api来拉回json并设置一些属性来将数据绑定到grid / handle错误。

2 个答案:

答案 0 :(得分:4)

您可以将loadComplete用作“afterSort”事件。这是非常好的地方。如果需要,您可以在onSortCol事件中设置一些变量并对其进行测试,然后在loadComplete内重置它。通过这种方式,您可以区分网格的重新加载,因为由于其他原因而改变排序顺序和重新加载网格。

顺便说一下jqGrid有内部行索引。它是_index。有关其他信息,请查看the answer。此外,您可以使用jqGrid的getLocalRow方法,通过rowid引用data中的项目。如果需要,您可以修改getLocalRow方法返回的对象的任何属性。

更新:在您发送给我的电子邮件中,我知道您在从服务器加载数据后,使用data方法设置jqGrid的setGridParam参数。如果您必须通过调用_index方法重建另一个内部jqGrid参数refreshIndex。该方法是表DOM的expando,相应的调用看起来像$("#grid")[0].refreshIndex()

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

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

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

答案 1 :(得分:0)

它使用jQuery-UI sortable,其中包括一个sort stop事件。你可以用它来听,

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

我没有对此进行测试,所以我不确定你需要在网格中找到哪个元素。