Skip to content

Instantly share code, notes, and snippets.

@KarateJB
Created May 9, 2017 02:11
Show Gist options
  • Save KarateJB/616485adb4a026ffe29185ebaf6664a9 to your computer and use it in GitHub Desktop.
Save KarateJB/616485adb4a026ffe29185ebaf6664a9 to your computer and use it in GitHub Desktop.
[JS] jqGri Deal with cells
var grid = $("#" + jqGridID);
var rows = grid.jqGrid('getGridParam', 'data'); //var rows = grid.getGridParam('data');
var indexes = grid.jqGrid('getGridParam', '_index');
var rowid;
for (rowid in indexes) {
if (indexes.hasOwnProperty(rowid)) {
let row = base.Materials.find(x => x.rowId == rowid);
//Set default value
row.sapOrigCcyAmt = importMaterialStg.calSapOrigCcyAmt(row.LSMNG, row.NETPR);
row.purchaseAmt = importMaterialStg.calPurchaseAmt(row.LSMNG, row.NETPR, row.Rate, base.SumPrice, base.DeclareFreight, base.DeclarePremium, base.DeclareCharges);
row.estimatedTariffs = importMaterialStg.calEstimatedTariffs(row.PurchaseAmt, row.Tariff, row.specialTariff, row.OtherTax);
if (changedCellTitle != "SAPTariff") //When not editting SAPTariff, calculate the new value
row.SapTariff = importMaterialStg.calSAPTariff(row.EstimatedTariffs, row.OtherTaxVal, base.SumEstimatedTariffs, base.SumOtherTaxVal, base.TariffVal);
//Rebind value
grid.jqGrid('setCell', rowid, 'SapOrigCcyAmt', row.SapOrigCcyAmt);
grid.jqGrid('setCell', rowid, 'PurchaseAmt', row.PurchaseAmt);
grid.jqGrid('setCell', rowid, 'EstimatedTariffs', row.EstimatedTariffs);
grid.jqGrid('setCell', rowid, 'OtherTaxVal', row.OtherTaxVal);
grid.jqGrid('setCell', rowid, 'SAPTariff', row.SapTariff);
//Get cell value
//var otherTaxVal = grid.jqGrid('getCell', rowid, 'OtherTaxVal');
// first change the cell in the visible part of grid
// now change the internal local data
//myGrid.jqGrid('getLocalRow', rowid).order = newvalue;
// and now sort
//myGrid.jqGrid("sortGrid", "order", true);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment