RadzenDataGrid not loading on first render when another component use AllowVirtualization and async LoadData #1092

Open
opened 2026-01-29 17:48:49 +00:00 by claunia · 0 comments
Owner

Originally created by @egans146 on GitHub (Jan 16, 2024).

Describe the bug
I encountered this issue when using a RadzenDropDown with AllowVirtualization=true and async LoadData, and at the same time a DataGrid with AllowVirtualization=true and async LoadData.
The component below reproduces this issue; the datagrid is not populated on first load, but if you comment out the dropdown or manually call RefreshDataAsync with the Refresh button, LoadData is called and the datagrid is populated:

<RadzenDropDown TValue=Item
                AllowVirtualization=true
                LoadData="OnDropDownLoadData"
                Data="dropDownItems"
                Count="dropDownItemCount" />

<RadzenDataGrid @ref=grid AllowVirtualization=true
                LoadData="OnGridLoadData"
                Data="gridItems"
                Count=gridItemCount
                Style="height: 30rem;">
    <Columns>
        <RadzenDataGridColumn TItem="Item" Property="@nameof(Item.Value)" Title="Value" />
    </Columns>
</RadzenDataGrid>

<RadzenButton Click="() => grid.RefreshDataAsync()">Refresh</RadzenButton>

@code {
    class Item(int value) { public int Value { get; } = value; };

    RadzenDataGrid<Item> grid;

    int dropDownItemCount;
    IEnumerable<Item> dropDownItems;

    async Task OnDropDownLoadData(LoadDataArgs args)
    {
        await Task.Delay(1);
        dropDownItemCount = 100;
        dropDownItems = Enumerable.Range(args.Skip ?? 0, args.Top ?? 10).Select(e => new Item(e)).ToArray();
        StateHasChanged();
    }

    int gridItemCount;
    IEnumerable<Item> gridItems;

    async Task OnGridLoadData(LoadDataArgs args)
    {
        await Task.Delay(100);
        gridItemCount = 100;
        gridItems = Enumerable.Range(args.Skip ?? 0, args.Top ?? 10).Select(e => new Item(e)).ToArray();
        StateHasChanged();
    }
}

Trying out different versions of Radzen, I found it was working in version 4.15.12. By reverting 5995eb8, it seems to correct the issue, but I'm not sure it would be adequate.

Expected behavior
RadzenDataGrid should load data and render properly when rendered with other components using AllowVirtualization and async LoadData.

Desktop:

  • OS: Windows
  • Browser: chrome
  • Version 4.24.0
Originally created by @egans146 on GitHub (Jan 16, 2024). <!-- IMPORTANT: Read this first!!! 1. If you own a Radzen Professional or Еnterprise subscription you can report your issue or ask us a question via email at info@radzen.com. Radzen staff will reply within 24 hours (Professional) or 16 hours (Enterprise) 2. The Radzen staff guarantees a response to issues in this repo only to paid subscribers. 3. If you have a HOW TO question start a new forum thread in the Radzen Community forum: https://forum.radzen.com. Radzen staff will close issues that are HOWTO questions. 4. Please adhere to the issue template. Specify all the steps required to reproduce the issue or link a project which reproduces it easily (without requiring extra steps such as restoring a database). --> **Describe the bug** I encountered this issue when using a RadzenDropDown with AllowVirtualization=true and async LoadData, and at the same time a DataGrid with AllowVirtualization=true and async LoadData. The component below reproduces this issue; the datagrid is not populated on first load, but if you comment out the dropdown or manually call RefreshDataAsync with the Refresh button, LoadData is called and the datagrid is populated: ```razor <RadzenDropDown TValue=Item AllowVirtualization=true LoadData="OnDropDownLoadData" Data="dropDownItems" Count="dropDownItemCount" /> <RadzenDataGrid @ref=grid AllowVirtualization=true LoadData="OnGridLoadData" Data="gridItems" Count=gridItemCount Style="height: 30rem;"> <Columns> <RadzenDataGridColumn TItem="Item" Property="@nameof(Item.Value)" Title="Value" /> </Columns> </RadzenDataGrid> <RadzenButton Click="() => grid.RefreshDataAsync()">Refresh</RadzenButton> @code { class Item(int value) { public int Value { get; } = value; }; RadzenDataGrid<Item> grid; int dropDownItemCount; IEnumerable<Item> dropDownItems; async Task OnDropDownLoadData(LoadDataArgs args) { await Task.Delay(1); dropDownItemCount = 100; dropDownItems = Enumerable.Range(args.Skip ?? 0, args.Top ?? 10).Select(e => new Item(e)).ToArray(); StateHasChanged(); } int gridItemCount; IEnumerable<Item> gridItems; async Task OnGridLoadData(LoadDataArgs args) { await Task.Delay(100); gridItemCount = 100; gridItems = Enumerable.Range(args.Skip ?? 0, args.Top ?? 10).Select(e => new Item(e)).ToArray(); StateHasChanged(); } } ``` Trying out different versions of Radzen, I found it was working in version 4.15.12. By reverting 5995eb8, it seems to correct the issue, but I'm not sure it would be adequate. **Expected behavior** RadzenDataGrid should load data and render properly when rendered with other components using AllowVirtualization and async LoadData. **Desktop:** - OS: Windows - Browser: chrome - Version 4.24.0
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/radzen-blazor#1092