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
    };
}

3 つのレコードの 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」イベントとしてそのまま使用できます。そういうアクションには本当にいいところです。必要に応じて、onSortColイベント内に変数を設定してテストし、内でリセットすることができloadCompleteます。このようにして、ソート順の変更によるグリッドの再ロードと、他の理由によるグリッドの再ロードを区別できます。

ところで、jqGrid には内部的に行インデックスがあります。です_index。追加情報については、たとえば回答を見てください。さらに、rowidで項目への参照を取得する jqGrid のgetLocalRowdataメソッドを使用できます。必要に応じて、getLocalRowメソッドによって返されるオブジェクトの任意のプロパティを変更できます。

更新: あなたが私に送ったメールから、サーバーからデータをロードした後data、メソッドに関して jqGrid のパラメーターを設定したことがわかりました。メソッドを呼び出して、setGridParam別の内部 jqGrid パラメータを再構築する必要がある場合。メソッドはテーブル DOM の expando で、対応する呼び出しは のようになります。_indexrefreshIndex$("#grid")[0].refreshIndex()

ほとんどの場合、_index自動的に再構築されますが、あなたの場合は未定義です。_indexしたがって、メソッドを使用して手動で再構築するとrefreshIndex、問題が解決するはずです。

_indexの設定後、グリッドをリロードするdataに、を使用してリビルドすることをお勧めします。.trigger("reloadGrid")

refreshIndexmethodの使用法については、 answerを参照してください。

于 2012-05-08T21:34:35.443 に答える
1

ソート停止イベントを含むjQuery-UIソート可能を使用します。あなたはそれを聞くことができます、

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

私はこれをテストしなかったので、グリッド内のどの要素をリッスンする必要があるかわかりません。

于 2012-05-08T21:23:00.270 に答える