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

This solution works fine if there are records. But when there are no records and I attempt to add nothing is visible.

Greetings to all. I have the same problem. I am not using DataLoad. If there are no records, no new row is inserted. In the old RadzenGrid, this problem was not observed.

Hi jbackslash. If you managed to solve this problem, then please give me a solution.

Hi! Your also need to set your RecordCount property in Grid.
public async Task InsertDHL()
{
var letter = new DHLLetter();
Letters.Insert(0,letter);
await DHLGrid.EditRow(letter);
RecordCount = Letters.Count;
}

Dmitry, thank you for your answer. That helped me.