Hello everyone,
I am new to radzen blazor and it is my first web application with this framework. I am using a DataGrid to show some information and I am noticing very poor performance when loading or switching pages. I am fetching the data async from a web service and bind them as a list to the DataGrid. Inside the grid, I am generating dynamic colums, based on other fetched data inside a loop. I even tried it with virtualization, did not increase the performance. It takes several seconds loading the grid.
I stripped my example to the bare minimum in order to provide some code:
<RadzenDataGrid
@ref="dataGridSites"
Data="sitesFiltered"
AllowSorting="true"
AllowPaging="true"
PageSize="10"
ShowPagingSummary="true"
PagingSummaryFormat="@pagingSummaryFormat"
IsLoading="_isLoading">
<Columns>
<RadzenDataGridColumn TItem="Site" Property="@nameof(Site.Id)" Title="Site Id" />
<RadzenDataGridColumn TItem="Site" Property="@nameof(Site.Name)" Title="Site Name" />
@foreach (var type in _types)
{
<RadzenDataGridColumn TItem="Site" Title="@type.Name">
<Template Context="site">
@{
var result = site.Results.Where(result => result.TypeName.Equals(type.Name)).First() ?? new Result(type.Name);
}
@if (result.LastDate != null)
{
<RadzenRow>
<RadzenColumn Size="3">
<RadzenText Text="Last:" />
</RadzenColumn>
<RadzenColumn Size="9">
<RadzenText Text="@result.LastDate.ToString()" />
</RadzenColumn>
</RadzenRow>
}
}
</Columns>
</RadzenDataGrid>
private List<Site> sitesFiltered = [];
protected override async Task OnInitializedAsync()
{
_isLoading = true;
sitesFiltered = await SiteService.GetSitesAsync();
[...]
_isLoading = false;
}
I am sure I am missing something, as your examples regarding DataGrid are way more complex and its responsiveness is very snappy. What am I doing wrong?