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

How to implement non source use of datafilter

1 Answer 77 Views
This is a migrated thread and some comments may be shown as answers.
Top achievements
Rank 1
Paw asked on 23 Aug 2010, 09:44 PM


The following little example should illustrate my problem.

I have three classes in my system:

1. Class Person
  - Name
  - Age.

2. Class Student : Person (Inherites from Person)
  - Grade

3. Class Teacher : Person (Inherites from Person)
  - Wage level

My system holds a complete list of Teachers and students like


I have different kinds of GUI controls (listview and radCarousel sofar) that binds to this collection. If I use the radFilterData component in source mode then I see only Name and Age in the field selector. I want to be able to see Name, Age, Grade, Wage level eventhough some of them only makes sence according a specific person type. I use ItemProperties and non source mode to archieve that.

My problem is that I am a little bit confused how to do the rest. I have seen the Domain examples but doesn't guite get it. I assume I have to handle this event:

  radDataFilter.FilterDescriptors.CollectionChanged += this.OnRadDataFilterDescriptorsChanged;

But how should I do that. I should also say that I have already implemented sorting and grouping using the


Hopefully I will be able to have sorting, grouping and filtering working side by side. 

1 Answer, 1 is accepted

Sort by
Rossen Hristov
Telerik team
answered on 24 Aug 2010, 08:53 AM
Hi Paw,

I am afraid that mixing Students and Teachers in the same list will complicate things enormously.

We have an extension method called .Where that can filter an IQueryable based on a collection of FilterDescriptors, but you will not be able to use it if your collection is heterogeneous, because an exception will be raised if you try to filter on a property that is not a member of the base Person class.

Your only option would be to attach to the two events of the FilterDescriptors collection:

- CollectionChanged
- ItemChanged

In the event handler of these two events you will receive notification about what is changed -- either a descriptor was added/removed or a property of an existing descriptor was changed.

From then on, you will have to devise a way to transfer this filtering information to your CollectionViewSource. Maybe you can use its Filter event to translate the information stored in RadDataFilter.FilterDescriptors to your CollectionViewSource.

I hope this helps.

the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
Asked by
Top achievements
Rank 1
Answers by
Rossen Hristov
Telerik team
Share this question