I need to manipulate a local array based on the sort order in my jqGrid as I'm using row indexes to modifiy the local data array which stuffs up when the grid is sorted by an alternate column. I can see the jqGrid has an onSortCol
event that fires after the header is clicked but before the sort but nothing called after the sort. I can't see anything in the documentation that I could hook into? Any ideas?
EDIT: Adding some code
This is the full extent of my jqGrid code:
$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 });
Here is where the data is loaded into the grid and a formatting function for the 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
};
}
Here's some json for three records.
{"_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"}}]}
Note I upgraded to jqGrid 4.3.2 but that had no effect. Let me know if posting the Loader code would help but it's really only a call to our api to pull back the json and set some properties to bind the data to the grid/handle errors.
You can just use loadComplete
as "afterSort" event. It is really good place for such actions. If needed you can set some variable inside of onSortCol
event and test it and then reset it inside of loadComplete
. In the way you will be able to distinguish reloading of the grid because of changing sort order from reloading of the grid because of other reasons.
By the way jqGrid has internally row indexes. It's _index
. Look at the answer for example for additional information. Moreover you can use getLocalRow method of jqGrid which get you reference to the item in the data
by rowid. If needed you can modify any property of the object returned by getLocalRow method.
UPDATED: From the email which you sent me I know that you set data
parameter of jqGrid with respect of setGridParam
method after loading of the data from the server. In the case you have to rebuild another internal jqGrid parameter _index
by calling of refreshIndex
method. The method is expando of table DOM, the corresponding call looks like $("#grid")[0].refreshIndex()
.
In the most cases the _index
will be rebuild automatically, but in your case it is undefined. So I think that manual rebuilding of _index
using refreshIndex
method should solve your problem.
I recommend you to rebuild _index
after setting of data
and before reloading of the grid using .trigger("reloadGrid")
.
You can find more about the usage of refreshIndex
method in the answer.
It uses jQuery-UI sortable which includes a sort stop event. You can listen on it with,
$('#jqgrid').on( "sortstop", function(event, ui) {
...
});
I didn't test this so I'm not certain which element in the grid you will need to listen on.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With