Skip to main content

ASPxClientGridView.BatchEditRowDeleting Event

Fires on the client side before a data row is marked as deleted in batch edit mode.

Declaration

BatchEditRowDeleting: ASPxClientEvent<ASPxClientGridViewBatchEditRowDeletingEventHandler<ASPxClientGridView>>

Event Data

The BatchEditRowDeleting event's data class is ASPxClientGridViewBatchEditRowDeletingEventArgs. 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.
key Gets the row’s key.
rowValues Gets a hashtable that maintains information about deleted cells.
visibleIndex Gets the processed row’s visible index.

Remarks

The BatchEditRowDeleting event fires in the following cases:

The rowValues argument property allows you to get information about the row marked as deleted. The data cells within this row are specified by the column indexes.

ASPxGridView.BatchEditMode - RowDeleting

rowValues = {
    2: {value: 'Maria Anders', text: 'Maria Anders'}
    3: {value: 'Alfreds Futterkiste', text: 'Alfreds Futterkiste'}
    4: {value: 'Germany', text: 'Germany'}
}

In the BatchEditRowDeleting event handler, you can set the cancel argument property to true to cancel the current deleting operation.

Example

The code sample below demonstrates how to handle the client-side BatchEditRowDeleting event and change the check state of the checkbox in the Discontinued column header.

View Example: ASPxGridView in Batch Edit mode - Implement the Select All feature for the CheckBox column

<dx:ASPxGridView ID="ASPxGridView1" runat="server" DataSourceID="AccessDataSource1" AutoGenerateColumns="False" ClientInstanceName="Grid" KeyFieldName="ProductID"
    OnCustomErrorText="ASPxGridView1_CustomErrorText" OnRowUpdating="ASPxGridView1_RowUpdating">
    <SettingsEditing Mode="Batch">
    </SettingsEditing>
    <ClientSideEvents BatchEditRowDeleting="OnBatchEditRowDeleting" BatchEditEndEditing="OnBatchEditEndEditing"
        BatchEditRowInserting="OnBatchEditRowInserting" />
        <!-- ... -->
    <Columns>
    <!-- ... -->
        <dx:GridViewDataCheckColumn FieldName="Discontinued" VisibleIndex="6">
        <!-- ... -->
            <HeaderTemplate>
                <dx:ASPxCheckBox ID="HeaderCheckBox" ClientIDMode="Static" runat="server" ClientInstanceName="HeaderCheckBox" AllowGrayed="true" AllowGrayedByClick="false">
                <!-- ... -->
                </dx:ASPxCheckBox>
            </HeaderTemplate>
            <!-- ... -->
        </dx:GridViewDataCheckColumn>
    </Columns>
</dx:ASPxGridView>
function OnBatchEditRowDeleting(s, e) {
    DeletedValue = Grid.batchEditApi.GetCellValue(e.visibleIndex, "Discontinued");
    CheckSelectedCellsOnPage("deleteCheck");
}
function CheckSelectedCellsOnPage(checkType) {
    var currentlySelectedRowsCount = 0;
    var visibleIndices = Grid.batchEditApi.GetRowVisibleIndices();
    var totalRowsCountOnPage = visibleIndices.length;
    for (var i = 0; i < totalRowsCountOnPage ; i++) {
        if (Grid.batchEditApi.GetCellValue(visibleIndices[i], "Discontinued"))
            currentlySelectedRowsCount++;
    }
    else if (checkType == "deleteCheck") {
        totalRowsCountOnPage--;
        if (DeletedValue)
            currentlySelectedRowsCount--;
    }
    if (currentlySelectedRowsCount <= 0)
        HeaderCheckBox.SetCheckState("Unchecked");
    else if (currentlySelectedRowsCount >= totalRowsCountOnPage)
        HeaderCheckBox.SetCheckState("Checked");
    else
        HeaderCheckBox.SetCheckState("Indeterminate");
}
See Also