DxDataGrid<T>.StartRowEdit(Object) Method

Asynchronously displays the edit form for the specified data row or a new row.

Namespace: DevExpress.Blazor

Assembly: DevExpress.Blazor.v21.1.dll

Declaration

public Task StartRowEdit(
    object dataItem
)

Parameters

Name Type Description
dataItem Object

A data item that corresponds to the data row. Pass null to invoke the edit form for a new data row.

Returns

Type Description
Task

An asynchronous operation that invokes the edit form.

Remarks

Use the StartRowEdit method to edit/insert a row in the Data Grid from code. This method allows you to implement custom edit buttons inside any Data Grid cell or outside the Data Grid.

<button id="newRowButton" @onclick="@NewRow">New Row</button>
<button id="editRowButton" @onclick="@EditRow">Edit Row</button>

<DxDataGrid DataAsync="@ForecastService.GetForecastAsync"
            @ref="MyGrid" 
            @bind-SingleSelectedDataRow="@selectedForecast" ...>
        <DxDataGridColumn Field=@nameof(WeatherForecast.TemperatureC) Caption="Temp. (C)"></DxDataGridColumn>
        ...
</DxDataGrid>

@functions {
    DevExpress.Blazor.DxDataGrid<WeatherForecast> MyGrid;
    WeatherForecast selectedForecast;

    async Task EditRow() {
        if (selectedForecast != null) {
            await MyGrid.StartRowEdit(selectedForecast);
        }
    }

    async Task NewRow() {
        await MyGrid.StartRowEdit(null);
    }
}

When you call the StartRowEdit method to edit a data row, the RowEditStart and RowEditStartAsync event fire. When you call this method to add a new row, the RowInsertStart and RowInsertStartAsync event occur.

See Also