Intersoft WebGrid Documentation
How-to: Calculate a cell after a value is filled
See Also Send comments on this topic.

Glossary Item Box

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.

  1. Use NorthWind database (table : Order Details).
  2. Add OnExitEditMode client side event

    JavaScript Copy ImageCopy 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

See Also

©2012 Intersoft Solutions Corp. All Rights Reserved.