ASPxClientGridView.BatchEditChangesCanceling Event
Fires before the grid discards changes in batch edit mode.
Declaration
BatchEditChangesCanceling: ASPxClientEvent<ASPxClientGridViewBatchEditChangesCancelingEventHandler<ASPxClientGridView>>
Event Data
The BatchEditChangesCanceling event's data class is ASPxClientGridViewBatchEditChangesCancelingEventArgs. 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. |
deletedValues | Gets a hashtable that maintains information about deleted cells. |
insertedValues | Gets a hashtable that maintains information about inserted cells. |
updatedValues | Gets a hashtable that maintains information about updated cells. |
Remarks
The BatchEditChangesCanceling
event fires in the following cases:
- A user clicks the Cancel changes button.
- You call the grid’s client-side CancelEdit method.
In the event handler, use the deletedValues, insertedValues, and updatedValues argument properties to get information about deleted, inserted, and updated rows.
The grid uses visible row indexes to identify modified rows, and column indexes to identify modified cells.
deletedValues = {
1: {2: 'Ana Trujillo', 3: 'Ana Trujillo Emparedados y helados', 4: 'Mexico'}
}
insertedValues = {
-1: {2: 'New contact name', 3: null, 4: null}
}
updatedValues = {
0: {4: 'Austria'}
}
To disable the current canceling operation, set the cancel argument property to true
.
The following example demonstrates how to handle the BatchEditChangesCanceling
event to discard batch changes in a templated column:
<dx:ASPxGridView ID="gridView" runat="server" KeyFieldName="ID" AutoGenerateColumns="False" ClientInstanceName="grid">
<Columns>
<!-- ... -->
<dx:GridViewDataColumn Name="num" FieldName="num">
<DataItemTemplate>
<div style="background-color: aquamarine; color:darkgreen; min-width: 50px; text-align: center; height: 100%" id="tmpl<%# Container.VisibleIndex %>"><%# Eval("num")%> </div>
</DataItemTemplate>
</dx:GridViewDataColumn>
<!-- ... -->
</Columns>
<SettingsEditing Mode="Batch" />
<ClientSideEvents BatchEditEndEditing="batchEndEdit" Init="gridInit" BatchEditChangesCanceling="onBatchEditChangesCanceling" />
</dx:ASPxGridView>
var rateColumnIndex = 0,
templateColumnIndex = 1,
barColumnIndex = 3;
// ...
function onBatchEditChangesCanceling(s, e) {
var updValues = e.updatedValues;
for (var rowIndex in updValues) {
for (var columnIndex in updValues[rowIndex]) {
var visibleIndex = parseInt(rowIndex);
var columnId = parseInt(columnIndex);
var initialVal = grid.batchEditApi.GetCellValue(visibleIndex, columnId, true);
var rateColumn, barColumn, templateColumn;
if (columnId == rateColumnIndex) {
rateColumn = grid.GetColumn(rateColumnIndex);
SetColValue(visibleIndex, rateColumn, initialVal);
}
// ...
}
}
}
// ...
function SetColValue(visibleIndex, column, rowValue) {
// ...
}