DataGrid LoadData fires multiple times!

I'm having an issue with the DataGrid. LoadData Event is fired 4 times when it first loads and when I try to navigate to another page it fires 5 times. If the pageSize is set to 2 and I try to navigate to the second page the skip and top will be:

  • skip 2, top 2
  • skip 0, top 2
  • skip 2, top 10
  • skip 0, top 2
  • skip 0, top 2

I tried to remove all async operations but no change. I realy don't know what I'm doing wrong.

Visual studio 2022, server Blazor, Radzen.Blazor version is 3.12.3

    <RadzenDataGrid @ref="grid" AllowVirtualization="true" Count="@_count" Data="@Articole" LoadData="@LoadData"
                    AllowSorting="true" AllowFiltering="true" FilterCaseSensitivity="FilterCaseSensitivity.CaseInsensitive" FilterMode="FilterMode.Simple"
                    AllowPaging="true" PageSize="2" TItem="Articol" RowSelect="SelectRow">
    RadzenDataGrid<Articol> grid;
    private int _count;
    private IEnumerable<Articol> Articole;

Also If I'm not using this event, the Single selection is not working.

   private void SelectRow(Articol obj)
        SelectedArticol = obj;
  private async Task LoadData(LoadDataArgs args)

        var query = context.Articole.AsQueryable();

        if (!string.IsNullOrEmpty(args.Filter))
            query = query.Where(args.Filter);

        if (!string.IsNullOrEmpty(args.OrderBy))
            query = query.OrderBy(args.OrderBy);

        _count = query.Count();
        var skip = args.Skip.Value;
        var top = args.Top.Value;
        Articole =await  query.Skip(args.Skip.Value).Take(args.Top.Value).ToListAsync();

You have virtualization turned on but no height is defined and PageSize is set to 2 - not sure what is going to be virtualized at all.

1 Like

Oh God. Thank you. It works as expected.