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

Iterating over filter expressions

4 Answers 136 Views
Filter
This is a migrated thread and some comments may be shown as answers.
Charlie
Top achievements
Rank 1
Charlie asked on 10 Jun 2011, 05:02 PM
In the ApplyExpressions event, I need to iterate over the RadFilterApplyExpressionsEventArgs.Expressions collection.  It appears that to access specific values of each filter expression (field name, field type, view state, value, etc.), you need to cast each filter expression to its specific derived type.  The only property exposed at the RadFilterExpression base type level is FilterFunction.

Basically I'm looking for the best way to iterate over a collection RadFilterExpressions, and access the specific properties of each instance.  What makes this a little more complex that you'd expect is that each filter expression is composed of a number derived types - with the filter properties and values exposed by different types in the chain.  What's the best way to access the specific filter expression properties?

Can anyone point me to a code example? 

4 Answers, 1 is accepted

Sort by
0
Pavlina
Telerik team
answered on 15 Jun 2011, 03:42 PM
Hello Charlie,

In general on ApplyExpressions event you have access to e.ExpressionRoot which contains the root of all build expressions. However, you can modify and get reference to the RadFilter expressions using RootGroup property and from there access the expressions, filter functions, values etc. for the filter control:

string fieldName = RadFilter1.FieldEditors[0].FieldName; // name of the field that we are filtering on  
                RadFilterFunction filterFunction = RadFilter1.RootGroup.Expressions[0].FilterFunction; // the filter function that was used for filtering  
                RadFilterNonGroupExpression nonGroupExpression = RadFilter1.RootGroup.FindByFieldName(fieldName);   
                RadFilterGreaterThanFilterExpression<int> expression = nonGroupExpression as RadFilterGreaterThanFilterExpression<int>;  
                int value = expression.Value; //the value that we filtered on (e.g. 10250)

Best wishes,
Pavlina
the Telerik team

Browse the vast support resources we have to jump start your development with RadControls for ASP.NET AJAX. See how to integrate our AJAX controls seamlessly in SharePoint 2007/2010 visiting our common SharePoint portal.

0
Charlie
Top achievements
Rank 1
answered on 16 Jun 2011, 12:08 AM
This is helpful, thank you.

But what I really need to do is iterate over the collection in such a way that I can capture the tree.  For each filter expression, I need to know what it's parent is.  In this case I assume that would be the Group the expression belongs to.

Another approach would be to get the Group tree (Group, ParentGroup; Group; ParentGroup, etc), and then determine which group a filter expression belongs to.

Must be possible - can you point me to a code example?

thanks
0
Pavlina
Telerik team
answered on 21 Jun 2011, 12:18 PM
Hi Charlie,

Please refer to the forum thread below for more information about group root expression item:
http://www.telerik.com/community/forums/aspnet-ajax/filter/filter-usablity.aspx

Regards,
Pavlina
the Telerik team

Browse the vast support resources we have to jump start your development with RadControls for ASP.NET AJAX. See how to integrate our AJAX controls seamlessly in SharePoint 2007/2010 visiting our common SharePoint portal.

0
Brian Pratt
Top achievements
Rank 1
answered on 21 Jun 2011, 12:58 PM
I had a need to iterate over the filter collection to get the preview string out.  Here's a link to my forum post that uses recursion to traverse the tree:

http://www.telerik.com/community/forums/aspnet-ajax/filter/how-to-get-the-preview-string.aspx

Hope it helps,
Brian
Tags
Filter
Asked by
Charlie
Top achievements
Rank 1
Answers by
Pavlina
Telerik team
Charlie
Top achievements
Rank 1
Brian Pratt
Top achievements
Rank 1
Share this question
or