Skip to content

Latest commit

 

History

History
57 lines (41 loc) · 3.87 KB

File metadata and controls

57 lines (41 loc) · 3.87 KB

GridView for Web Forms - How to calculate values dynamically in batch edit mode

This example demonstrates how to create an unbound column (Sum) that changes its values based on other column values dynamically in batch edit mode.

Grid View - Modified values

Set the unbound column's ShowEditorInBatchEditMode property to false to make the column read-only in batch edit mode.

<dx:GridViewDataTextColumn FieldName="Sum" UnboundType="Decimal" ReadOnly="true">
    <Settings ShowEditorInBatchEditMode="false" />
</dx:GridViewDataTextColumn>

Handle the client BatchEditEndEditing event to recalculate column values based on the changes and call the SetCellValue method to set the new column value.

function OnBatchEditEndEditing(s, e) {
    window.setTimeout(function () {
        var price = s.batchEditApi.GetCellValue(e.visibleIndex, "Price");
        var quantity = s.batchEditApi.GetCellValue(e.visibleIndex, "Quantity");
        s.batchEditApi.SetCellValue(e.visibleIndex, "Sum", price * quantity, null, true);
    }, 0);
}

Files to Look At

Documentation

More Examples

Does this example address your development requirements/objectives?

(you will be redirected to DevExpress.com to submit your response)