I have a DataGrid with data populated from LoadData event and bound Settings. I want to dynamically change DataGrid's PageSize at runtime. The problem is that after SettingsChanged event has been triggered, a change in PageSize causes an infinite loop. Please see provided code example and screen recording for details.
@using System.Linq.Dynamic.Core;
Page Size:
<RadzenNumeric @bind-Value="PageSize" />
<RadzenDataGrid TItem="DataRow" Data="Data" Count="DataCount" LoadData="LoadData" IsLoading="IsLoading"
AllowSorting="true" AllowPaging="true" PageSize="PageSize" @bind-Settings="Settings">
<Columns>
<RadzenDataGridColumn TItem="DataRow" Title="Value" Property="Value" />
</Columns>
</RadzenDataGrid>
@code {
public DataRow[]? Data { get; set; }
public int DataCount { get; set; }
public int PageSize { get; set; } = 4;
public DataGridSettings? Settings { get; set; }
public bool IsLoading { get; set; }
async Task LoadData(LoadDataArgs args)
{
IsLoading = true;
await Task.Yield();
DataCount = 10;
Data = Enumerable.Range(1, DataCount).Select(x => new DataRow { Value = x })
.Skip(args.Skip ?? 0).Take(args.Top ?? 0).ToArray();
IsLoading = false;
}
public class DataRow
{
public int Value { get; set; }
}
}