This is a migrated thread and some comments may be shown as answers.

RadListView re-apply filtering

2 Answers 41 Views
ListView
This is a migrated thread and some comments may be shown as answers.
Robin
Top achievements
Rank 1
Robin asked on 04 Mar 2021, 09:15 PM

Hi there,

I am using the RadListView on UWP.

I have applied filtering in XAML.  There are multiple filters applied.

How do I refresh one (or all) of those filters when an external comparison value changes?

 

For example;

Say you have a checkbox outside of the radlistview.  The listviews have a delegate filter comparing a property of each item in the collection to the checkbox boolean value.

When that checkbox boolean changes, you want to refresh/re-apply the filter.

How do I do this refresh?

Thanks,

Rob.

2 Answers, 1 is accepted

Sort by
0
Lance | Manager Technical Support
Telerik team
answered on 04 Mar 2021, 09:34 PM

Hello Rob,

The Key/Delegate of the filter descriptor doesn't listen for property changes, this would add too much overhead on your app's performance.

Instead, the fastest way to re-apply the filter is to call lv.FilterDescriptors.Clear() and re-add it using lv.FilterDescriptors.Add(..)

Here's a quick example:

// OPTION 1 (recommended)

// Clear the existing filters
myListView.FilterDescriptors.Clear();

// Add the newly formed descriptor
myListView.FilterDescriptors.Add(new BooleanFilterDescriptor { PropertyName="IsAbsent" , true});


// OPTION 2

// keep a class field copy the filter descriptor
TextFilterDescriptor myDescriptor;

// make change to the filter
myDescriptor = some updated version of that descriptor;

// Clear the existing filters
myListView.FilterDescriptors.Clear();

// Add the filter back
myListView.FilterDescriptors.Add(myDescriptor);

 

 

Side note: You might be able to artificially trigger a refresh by artificially invoking collectionchanged or propertychanged on the FilterDescriptors dependency property, but this is not something we recommend

Regards,
Lance | Manager Technical Support
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/.

0
Robin
Top achievements
Rank 1
answered on 04 Mar 2021, 09:42 PM

Hi Lance,

Firstly, thank you for the super prompt reply!

That solution of clearing and re-applying the filters can work for me.  I was hopeful I could do it without locating the control in the UI but that's not the end of the world.

I did try calling notifypropertychanged on the collection, and also on the filtered property in each object but to no avail.  I'll experiment with the collection changed theory while I am playing with this.

Most likely though, I'll end up with clearing and re-adding filters.

Thanks again!

Rob.

Tags
ListView
Asked by
Robin
Top achievements
Rank 1
Answers by
Lance | Manager Technical Support
Telerik team
Robin
Top achievements
Rank 1
Share this question
or