DxDataGrid<T>.RowInsertingAsync Event
Occurs when a user adds a new data row and allows you to await handler execution without blocking the Data Grid.
Namespace: DevExpress.Blazor
Assembly: DevExpress.Blazor.v22.1.dll
Declaration
[Parameter]
public Func<IDictionary<string, object>, Task> RowInsertingAsync { get; set; }
Parameters
Type | Description |
---|---|
IDictionary<String, Object> | A dictionary that lists column names and column values. |
Remarks
Important
The Data Grid was moved to maintenance support mode. No new features/capabilities will be added to this component. We recommend that you migrate to the Grid component.
When users click the New button in a command column, the grid displays the Edit Form where you can specify a new row’s data. To post new values to the Data Grid’s data source or discard these values, handle the RowInsertingAsync event.
To control the visibility of the New button, use the NewButtonVisible property.
@inject MyApp.Data.WeatherForecastService ForecastService
@using MyApp.Data
<DxDataGrid DataAsync="@ForecastService.GetForecastAsync"
RowInsertingAsync="@OnRowInserting"
InitNewRow="@OnInitNewRow">
<DxDataGridCommandColumn />
<DxDataGridDateEditColumn Field=@nameof(WeatherForecast.Date) />
<DxDataGridSpinEditColumn Field="@nameof(WeatherForecast.TemperatureC)"
Caption="@("Temp. (\x2103)")" />
<DxDataGridColumn Field=@nameof(WeatherForecast.TemperatureF) Caption="Temp. (F)" />
</DxDataGrid>
@code {
async Task OnRowInserting(IDictionary<string, object> newValue) {
await ForecastService.Insert(newValue);
}
Task OnInitNewRow(Dictionary<string, object> values) {
values.Add("Date", DateTime.Now);
values.Add("TemperatureC", 13);
return Task.CompletedTask;
}
}
Note
If you bind the data grid to a data source that does not implement the INotifyCollectionChanged interface, you should reload data and redraw the grid after a row is inserted. To do this, use the Refresh method in the OnRowInserting
handler.