DataGrid InLine Editing - Issue with InsertRow

Hi
I am having some trouble getting the InsertRow action to work when LoadData action is defined for the DataGrid.

If I remove the line: LoadData line then the InsertRow function works without issue.

Please see code below, any ideas what I am doing wrong please?

Markup

<RadzenButton Icon="add_circle_outline" style="margin-bottom: 10px" Text="Add" Click="@InsertRow" />
<RadzenGrid 
            @ref="transactionTypesGrid"
            TItem="TransactionType"
            AllowFiltering="true"
            AllowPaging="true"
            AllowSorting="true"
            PageSize="10"
            Data="@transactionTypeService.Data"
            Count="@transactionTypeService.Count"
            LoadData="@LoadDataAsync"
            RowCreate="@OnCreateRow"
            RowUpdate="@OnUpdateRow"
            EditMode="DataGridEditMode.Single">
    <Columns>
    </Columns>
</RadzenGrid>

Actions

async Task LoadDataAsync(LoadDataArgs loadDataArgs)
{
    if (loadDataArgs is not null && loadDataArgs.Top.HasValue)
    {
        transactionTypeService.PageSize = loadDataArgs.Top.Value;
    }

    if (loadDataArgs is not null && loadDataArgs.Skip.HasValue)
    {
        transactionTypeService.Skip = loadDataArgs.Skip.Value;
    }

    transactionTypeService.OrderBy = OrderBy.IdAsc;

    await transactionTypeService.OnGetAsync();
}

async Task InsertRow()
{
    await transactionTypesGrid.InsertRow(new TransactionType() { Name = "Change Me"});
}

Hi @Jordan,

Using our demo with DataGrid bound using LoadData you can try the following instead:


1 Like

Hi @enchev

Thank you for your help :slight_smile:

Jordan