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

[Solved] Custom Filter (multiple contains)

4 Answers 175 Views
GridView
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
Aaron Hanusa
Top achievements
Rank 1
Aaron Hanusa asked on 20 Sep 2010, 07:01 PM
Hi,

I need a custom filter so that the user can enter in a few different words that will perform a "contains" lookup on the entire string.  But by "contains", I don't mean the whole string.  Please take the following cell data as an example.  Below represents data from 2 cells for a detail column.

123 Main St. San Fransisco, CA, contact Joe
123 Main St. New York, NY, contact: Joe

So if the user enters "123 Joe", both of these records HAVE TO come up.

What is the best way to accomplish this?  It seems that I need to create a custom FilterDescriptor and make use of it in a custom filter control that implements IFilteringControl.  Am I on the right track?

Remember also that using the default FilterDescriptor, passing in FilterOperator.Contains to the constructor will NOT work.  I actually need to parse the user entered string (delimited by spaces), and perform a contains for each substring against each cell value.

So in the above example, I need to do a split against "123 Joe".  Then, I would check to see if one or both of those values is contained within the cells.

Thanks!

4 Answers, 1 is accepted

Sort by
0
Rossen Hristov
Telerik team
answered on 21 Sep 2010, 09:11 AM
Hi Aaron Hanusa,

The only way you can achieve this custom logic would be by developing your own custom filtering control like demonstrated in my blog post. In case the default FilterDescriptor does not suit your need you will have to implement the IFilterDescriptor interface and provide custom filtering logic.

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
0
Aaron Hanusa
Top achievements
Rank 1
answered on 21 Sep 2010, 10:09 PM
Thanks for the reply.  Do you have a sample of where you override IFilterDescriptor.CreateFilterExpression, and modify the expression passed in?
0
Accepted
Rossen Hristov
Telerik team
answered on 22 Sep 2010, 08:08 AM
Hello Aaron Hanusa,

Yes, my colleague Stefan Dobrev's blog post does this in the source code.

I hope this helps.

Sincerely yours,
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
0
Aaron Hanusa
Top achievements
Rank 1
answered on 22 Sep 2010, 03:31 PM
After downloading the code and viewing it, there are some helpful classes that facilitate converting the expression to a strongly typed expression, which is what I needed.

Thanks for your help!
Tags
GridView
Asked by
Aaron Hanusa
Top achievements
Rank 1
Answers by
Rossen Hristov
Telerik team
Aaron Hanusa
Top achievements
Rank 1
Share this question
or