Clear filter button does not work correctly in RadzenDataGrid
OndrejUzovic opened this issue · comments
When using RadzenDataGrid with LoadData, Virtualization and Simple Filter Mode, the clear button in the filter does not work correctly.
When clicking the clear button inside the filter, the filter is cleared but data grid does not show any data items.
Here is a short video showing the problem:
Here a simple code to reproduce the issue:
@page "/"
@using Radzen;
@using Radzen.Blazor;
@using System.Linq.Dynamic.Core
<RadzenDataGrid TItem="Dummy" LoadData="@OnLoadData" Data="@myLoadedData" Count="@myCount" AllowVirtualization=true
AllowFiltering=true FilterMode="FilterMode.Simple"
Style="width:400px; height:400px">
<Columns>
<RadzenDataGridColumn TItem="Dummy" Property="Id" Title="Id">
<FooterTemplate>
@myCount
</FooterTemplate>
</RadzenDataGridColumn>
</Columns>
</RadzenDataGrid>
@code {
private class Dummy
{
public string Id { get; set; }
}
private List<Dummy> myEmployees = new List<Dummy>();
private IEnumerable<Dummy> myLoadedData;
private int myCount;
protected override void OnInitialized()
{
for (int i = 0; i < 100; ++i)
{
myEmployees.Add(new Dummy() { Id = $"ID_{i.ToString()}" });
}
}
private void OnLoadData(LoadDataArgs args)
{
var query = myEmployees.AsQueryable();
if (!string.IsNullOrEmpty(args.Filter))
{
query = query.Where(args.Filter);
}
myCount = query.Count();
if (!string.IsNullOrEmpty(args.OrderBy))
{
query = query.OrderBy(args.OrderBy);
}
myLoadedData = query.Skip(args.Skip.Value).Take(args.Top.Value).ToList();
}
}
Please, would it be possible to provide a fix for this issue?
use async Task for LoadData as shown in our demos
Thank you very much for your quick response. Using async task really helped.