Skip to main content

ASPxClientGridView.BatchEditEndEditing Event

Fires before a cell/row switches from edit to browse mode.

Declaration

BatchEditEndEditing: ASPxClientEvent<ASPxClientGridViewBatchEditEndEditingEventHandler<ASPxClientGridView>>

Event Data

The BatchEditEndEditing event's data class is ASPxClientGridViewBatchEditEndEditingEventArgs. The following properties provide information specific to this event:

Property Description
cancel Specifies whether to cancel the related action (for example, row edit, export). Inherited from ASPxClientCancelEventArgs.
focusedColumn Gets the column to which the edited cell belongs.
key Gets the row’s key.
rowValues Gets a hashtable that maintains information about editable cells.
visibleIndex Gets the visible index of the row whose cells has been edited.

Remarks

The BatchEditEndEditing event fires in the following cases:

In the event handler, use the rowValues argument property to get all cell values of an edited row. The cell values are specified by the column indexes.

ASPxGridView.BatchEditMode - EndEditing

rowValues = {
    1: {value: 'Chai', text: 'Chai'}
    2: {value: 'Beverages', text: 'Beverages'}
    3: {value: '40', text: '40'}
}

To leave a cell in edit mode, set the cancel argument property to true.

function OnBatchEditEndEditing(s, e) {
    var columnIndex = e.focusedColumn.index;
    var newValue = e.rowValues[columnIndex].value;
    if (newValue === null)
        e.cancel = true;
}

Select a Modified Row

When the grid raises the BatchEditEndEditing event, the cell value is not updated yet. To select the modified row in the event handler, use the setTimeout function.

<dx:ASPxGridView ID="Grid" runat="server" ...>
    <!-- ... -->
    <SettingsEditing Mode="Batch" />
    <ClientSideEvents BatchEditEndEditing="OnBatchEditEndEditing" />
</dx:ASPxGridView>
function OnBatchEditEndEditing(s, e) {
    window.setTimeout(SelectModifiedRows, 0);

    function SelectModifiedRows() {
        if (s.batchEditApi.HasChanges(e.visibleIndex)) {
            s.SelectRowOnPage(e.visibleIndex);
        }
    }
}

Calculate Values Dynamically

The following axample demonstrates how to calculate values dynamically based on other column values in the BatchEditEndEditing event handler:

View Example: How to calculate values dynamically in batch edit mode

To enable this behavior, follow the steps below:

  1. Create an unbound column and set its 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>
    
  2. In the BatchEditEndEditing event handler, recalculate column values based on the changes and call the SetCellValue(visibleIndex, columnFieldNameOrId, value) 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);
        }, 10);
    }
    

Online Examples

View Example: How to use and modify a control placed in DataItemTemplate

View Example: Implement the Select All feature for the CheckBox column

View Example: How to update total summaries on the client side in Batch Edit mode

View Example: How to use an edit item and data item templates in batch mode

See Also