Declined
Last Updated: 08 Sep 2021 06:44 by ADMIN
Emmanuel
Created on: 01 Jul 2021 18:50
Category: Grid
Type: Bug Report
0
OnStateChanged : GridState has incorrect filters

Hello, 

After just a sort operation, in the event handler of OnStateChanged event, the FilterDescriptors of GridStateEventArgs.GridState is not empty. 

Steps to reproduce : 

1) Implement Grid with OnStateChanged and OnRead : 

<TelerikGrid 
             OnStateChanged="@((GridStateEventArgs<IGetAgences_Agences_Items> args) => OnStateChangedHandler(args))"
             OnRead=@ReadItems


    async Task OnStateChangedHandler(GridStateEventArgs<IGetAgences_Agences_Items> args)
    {
        var filters = args.GridState.FilterDescriptors; // filters are not empty after just a sort opration
      
    }

    async Task ReadItems(GridReadEventArgs args)
    {

        this.LoadData()

        await InvokeAsync(StateHasChanged);
    }

 

2) Sort a column 

3) The OnStateChanged event is fire

4) In the OnStateChangedHandler,  the filters are not empty : 

Expected behaviors :

If no filters added, the filters of the GridState must be empty 

 

Thank's

Thomas

 

 

 
3 comments
ADMIN
Dimo
Posted on: 08 Sep 2021 06:44

Hi Thomas,

The information from my previous post applies also when the Grid FilterMode is FilterMenu. You can still distinguish "inactive" filter descriptors by their null Value.

I will update the documentation to avoid confusion in the future.

On a side note, there is no need to inspect args.GridState.FilterDescriptors unless args.PropertyName is equal to "FilterDescriptors". Otherwise the filters either don't exist, or they are the same as before.

Regards,
Dimo
Progress Telerik

Love the Telerik and Kendo UI products and believe more people should try them? Invite a fellow developer to become a Progress customer and each of you can get a $50 Amazon gift voucher.

Emmanuel
Posted on: 07 Sep 2021 14:25

Hi Dimo,

Thank you for your answer ! 

No ! The observed behavior occurs without use a FilterMenuTemplate or a FilterCellTemplate.

Regards,

Thomas

 

 

ADMIN
Dimo
Posted on: 08 Jul 2021 07:52

Hi Emmanuel,

The observed behavior is expected when you use a FilterMenuTemplate or a FilterCellTemplate. Is this your scenario? In such cases, the filter descriptors exist, but their Values are null.

https://docs.telerik.com/blazor-ui/components/grid/state#set-grid-options-through-state

There are default filters in the grid state for each column. This allows filter menu templates to work seamlessly and with little code. This, however, means that if you want to alter filters for a column, you must either modify the existing one, or remove it. Simply adding a filter will not show up in the UI because the grid will use the first filter for the given field it finds for the filtering UI.

Regards,
Dimo
Progress Telerik

Virtual Classroom, the free self-paced technical training that gets you up to speed with Telerik and Kendo UI products quickly just got a fresh new look + new and improved content including a brand new Blazor course! Check it out at https://learn.telerik.com/.