RadGridView in wpf reset/clear filters when reloading data

1 Answer 127 Views
GridView
BrunoVT
Top achievements
Rank 1
BrunoVT asked on 03 Sep 2024, 12:21 PM

Hi,

When a user uses a filter on the RadgridView and then clicks a button to reload different data in the grid the filters are still there. Is there a way to clear these automatically when reloading data?

<telerik:RadGridView
                      ItemsSource="{Binding Data}"
                      CanUserInsertRows="False" />

1 Answer, 1 is accepted

Sort by
0
Martin Ivanov
Telerik team
answered on 05 Sep 2024, 03:40 PM

Hello Bruno,

There is no automatic mechanism that clears the filters on data reload, but you can do that manually whenever you update the ItemsSource.

// reload the data and then clear the FilterDescriptors collection
 this.gridView.FilterDescriptors.Clear();

Regards,
Martin Ivanov
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.

BrunoVT
Top achievements
Rank 1
commented on 06 Sep 2024, 07:13 AM

This indeed works but when I do this the filter UI popup is not cleared. How can I make sure the filter UIs are also reset to there default values?
Martin Ivanov
Telerik team
commented on 09 Sep 2024, 12:36 PM

You can also clear the ColumnFilterDescriptor of the columns, like so:

foreach (var column in gridView.Columns.OfType<GridViewDataColumn>())
{
    column.ColumnFilterDescriptor.Clear();
}

 

BrunoVT
Top achievements
Rank 1
commented on 09 Sep 2024, 01:14 PM

Yes, this fixes my issue. Thank you for the help.
Tags
GridView
Asked by
BrunoVT
Top achievements
Rank 1
Answers by
Martin Ivanov
Telerik team
Share this question
or