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

Filtering with Lists

1 Answer 44 Views
GridView
This is a migrated thread and some comments may be shown as answers.
David Harris
Top achievements
Rank 1
David Harris asked on 06 Jul 2010, 04:03 PM
I have a GridView with a bunch of DataColumns. I am filtering the grid programmatically, so... I want to filter based on the contents of a List.

Example: I have 3 types of equipment I can use: A, B, and C. I want to show only records where I used A, or A and C, etc.

I am using ColumnFilterDescriptors for moment - and for the rest of the columns, the DistinctFilters.DistinctValues work fine. Just not sure how to filter based on what's in the list.

1 Answer, 1 is accepted

Sort by
0
Rossen Hristov
Telerik team
answered on 07 Jul 2010, 12:50 PM
Hello David Harris,

Our FilterDescriptors support only "Member"-"Operator"-"Value" kind of constructions. So your only option would be to create another property on your business object class. For example it might be a string property that returns the contents of the list like this "A, B, C". Let's call it ListString. Then you can do something like:

ListString Contains "A"
ListString DoesNotContain "B"
etc.

You can also create the so-called CompositeFilterDescriptor which combines several simple FilterDescriptors with a logical operator.

So your CustomFilterDescirptor will have an operator AND and two child filters that will be:
ListString Contains "A"
ListString Contains "C"

You get the idea.

Another alternative is to implement the IFilterDescriptor interface yourself and provide this custom filtering logic. I have to warn you that this is far from trivial though. My colleague's blog post may inspire you to take this approach.

For general filtering information you can read my series of blog posts on the topic:
Custom Filtering
Pre-Filtering
Filtering Control
Pure-Server Side Filtering

I hope this helps.

Greetings,
Ross
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
Tags
GridView
Asked by
David Harris
Top achievements
Rank 1
Answers by
Rossen Hristov
Telerik team
Share this question
or