Skip to main content

ASPxClientGridView.BatchEditRowInserting Event

Fires before a data row is inserted in batch edit mode.

Declaration

BatchEditRowInserting: ASPxClientEvent<ASPxClientGridViewBatchEditRowInsertingEventHandler<ASPxClientGridView>>

Event Data

The BatchEditRowInserting event's data class is ASPxClientGridViewBatchEditRowInsertingEventArgs. 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.
visibleIndex Gets the processed row’s visible index.

Remarks

The client-side BatchEditRowInserting event fires in the following cases:

  • A user clicks the New command button.
  • You call the client-side AddNewRow method.

The code sample below handles the client-side BatchEditRowInserting event and changes the check state of the checkbox in the Discontinued column header.

<dx:ASPxGridView ID="ASPxGridView1" runat="server" ClientInstanceName="Grid" KeyFieldName="ProductID">
    <Columns>
        <dx:GridViewDataCheckColumn FieldName="Discontinued">
            <%--...--%>
            <HeaderTemplate>
                <dx:ASPxCheckBox ID="HeaderCheckBox" runat="server" AllowGrayed="true"
                    ClientInstanceName="HeaderCheckBox" ... >
                    <%--...--%>
                </dx:ASPxCheckBox>
            </HeaderTemplate>
        </dx:GridViewDataCheckColumn>
        <%--...--%>
    </Columns>
    <SettingsEditing Mode="Batch" />
    <ClientSideEvents BatchEditRowInserting="OnBatchEditRowInserting" />
</dx:ASPxGridView>
function OnBatchEditRowInserting(s, e) {
    CheckSelectedCellsOnPage("insertCheck");
}
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++;
    }
    if (checkType == "insertCheck")
        totalRowsCountOnPage++;

    if (currentlySelectedRowsCount <= 0)
        HeaderCheckBox.SetCheckState("Unchecked");
    else if (currentlySelectedRowsCount >= totalRowsCountOnPage)
        HeaderCheckBox.SetCheckState("Checked");
    else
        HeaderCheckBox.SetCheckState("Indeterminate");
}

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

See Also