Skip to main content

ASPxClientGridViewBatchEditApi.StartEditByKey(key, columnIndex) Method

Switches the specified cell to edit mode.

#Declaration

TypeScript
StartEditByKey(
    key: any,
    columnIndex: number
): void

#Parameters

Name Type Description
key any

The key value of the row that contains the processed cell.

columnIndex number

The index of the column that contains the processed cell.

#Remarks

When the GridView.SettingsEditing.Mode property is set to Batch, call the StartEditByKey method to switch the specified cell to edit mode.

The following example demonstrates how to switch a particular cell to edit mode in the BatchEditStartEditing event handler. Note that in this example, a StartEditByKey method call has no effect if the EditMode property is set to Row.

<dx:ASPxGridView ID="Grid" ClientInstanceName="ClientGrid" runat="server" KeyFieldName="ProductID"
    AutoGenerateColumns="False">
    <Columns>
        <!-- ... -->
        <dx:GridViewDataTextColumn FieldName="ProductName" VisibleIndex="2" />
        <dx:GridViewDataTextColumn FieldName="CategoryName" VisibleIndex="3" />
        <dx:GridViewDataTextColumn FieldName="UnitPrice" VisibleIndex="4" />
        <!-- ... -->
    </Columns>
    <SettingsEditing Mode="Batch" />
    <ClientSideEvents BatchEditStartEditing="OnBatchEditStartEditing" />
</dx:ASPxGridView>
function OnBatchEditStartEditing(s, e) {
    if (e.focusedColumn.fieldName == "ProductName" || e.focusedColumn.fieldName == "CategoryName") {
        e.cancel = true;

        var columnIndex = s.GetColumnByField('UnitPrice').index;
        window.setTimeout(function () {
            s.batchEditApi.StartEditByKey(e.key, columnIndex);
        }, 0);
    }
}
See Also