DxDataGridBase<T>.InitNewRow Event

Enables you to initialize added data rows.

Namespace: DevExpress.Blazor.Base

Assembly: DevExpress.Blazor.dll

Declaration

[Parameter]
public Func<Dictionary<string, object>, Task> InitNewRow { get; set; }

Parameters

Type Description
Dictionary<String, Object>

A dictionary that lists column names and column values.

Remarks

The InitNewRow event is raised when a user clicks the New button in the Data Grid's edit form. Handle this event to display predefined values in new rows. Use the event handler's parameter to add pairs of column names and column values.

<DxDataGrid DataAsync="@ForecastService.GetForecastAsync"  
            InitNewRow="@OnInitNewRow" ...>
    <DxDataGridCommandColumn></DxDataGridCommandColumn>
    <DxDataGridDateEditColumn Field="@nameof(WeatherForecast.Date)" DisplayFormatString="D" EditFormatString="D"></DxDataGridDateEditColumn>
    <DxDataGridColumn Field="@nameof(WeatherForecast.Summary)" Caption="Summary" Width="150px"></DxDataGridColumn>
    <DxDataGridSpinEditColumn Field="@nameof(WeatherForecast.TemperatureC)" Caption="@("Temp. (\x2103)")"></DxDataGridSpinEditColumn> 
    <DxDataGridComboBoxColumn Field="@nameof(WeatherForecast.WeatherType)" Caption="Cloudiness" 
        DataAsync="@ForecastService.GetCloudinessAsync"></DxDataGridComboBoxColumn>
</DxDataGrid>

@code {
    // ...
    Task OnInitNewRow (Dictionary<string, object> values) {
        values.Add("Date", DateTime.Now);
        values.Add("TemperatureC", 13);
        values.Add("Summary", "Warm");
        values.Add("WeatherType", "Sunny");
        return Task.CompletedTask;
    }
}

Blazor-Data-Grid-InitNewRow

Online Demo

Data Grid - Column Types

See Also