Sometimes when you finished editing a cell, you want other cell to be calculated based on the value that we have inputted.
In this topic, you will learn how to calculate a cell after a value is filled.
To calculate a cell after a value is filled.
- Use NorthWind database (table : Order Details).
- Add OnExitEditMode client side event
JavaScript Copy Code function WebGrid1_OnExitEditMode(controlId, tblName, editObject)
{
var WebGrid1 = ISGetObject(controlId);
var cell = wgGetCellByElement(editObject.cellElement);
var colName = cell.Name;
if(colName=="Quantity")
{
var row = cell.Row;
var disc = parseFloat(row.GetCells().GetNamedItem("Discount").Text);
var quantity = parseInt(editObject.element.value);
if(disc == 0) {
result = quantity;
}
else {
result = quantity * disc;
}
row.GetCells().GetNamedItem("UnitPrice").SetText(String(result), true);
}
return true
};
Column's UnitPrice value will be calculate based on Quantity * Discount |