Skip to content

Create an unbound column that changes its values based on other column values dynamically in batch edit mode.

License

Notifications You must be signed in to change notification settings

DevExpress-Examples/asp-net-mvc-grid-dynamic-calculation-in-batch-mode

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

29 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Grid View for ASP.NET MVC - 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.

Calculate values on dynamically

Overview

Follow the steps below:

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

    settings.Columns.Add(column => {
        column.UnboundType = DevExpress.Data.UnboundColumnType.Decimal;
        column.FieldName = "Sum";
        column.ReadOnly = true;
        column.Settings.ShowEditorInBatchEditMode = false;
    });
  2. Handle the grid's client-side BatchEditEndEditing event. In the handler, recalculate column values based on the changes and call the SetCellValue method to set the new column value.

    function OnBatchEditEndEditing(s, e) {
        var PriceColIndex = s.GetColumnByField("Price").index;
        var QuantityColIndex = s.GetColumnByField("Quantity").index;
        var priceValue = e.rowValues[PriceColIndex].value;
        var quantityValue = e.rowValues[QuantityColIndex].value;
        s.batchEditApi.SetCellValue(e.visibleIndex, "Sum", priceValue * quantityValue, null, true);
    }

Files to Review

Documentation

More Examples

Does this example address your development requirements/objectives?

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