Clear filter button does not work correctly in RadzenDataGrid #1212

Closed
opened 2026-01-29 17:50:32 +00:00 by claunia · 2 comments
Owner

Originally created by @OndrejUzovic on GitHub (Apr 25, 2024).

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:
Animation2

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?

Originally created by @OndrejUzovic on GitHub (Apr 25, 2024). 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: ![Animation2](https://github.com/radzenhq/radzen-blazor/assets/55758368/7999eae8-1fd6-4f81-be0d-793908071d62) 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?
Author
Owner

@enchev commented on GitHub (Apr 25, 2024):

use async Task for LoadData as shown in our demos

@enchev commented on GitHub (Apr 25, 2024): use async Task for LoadData as shown in our demos
Author
Owner

@OndrejUzovic commented on GitHub (Apr 25, 2024):

Thank you very much for your quick response. Using async task really helped.

@OndrejUzovic commented on GitHub (Apr 25, 2024): Thank you very much for your quick response. Using async task really helped.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/radzen-blazor#1212