Iterating over filter expressions

5 posts, 0 answers
  1. Charlie
    Charlie avatar
    4 posts
    Member since:
    Jun 2011

    Posted 10 Jun 2011 Link to this post

    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? 
  2. Pavlina
    Admin
    Pavlina avatar
    6084 posts

    Posted 15 Jun 2011 Link to this post

    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.

  3. UI for ASP.NET Ajax is Ready for VS 2017
  4. Charlie
    Charlie avatar
    4 posts
    Member since:
    Jun 2011

    Posted 15 Jun 2011 Link to this post

    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
  5. Pavlina
    Admin
    Pavlina avatar
    6084 posts

    Posted 21 Jun 2011 Link to this post

    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.

  6. Brian Pratt
    Brian Pratt avatar
    28 posts
    Member since:
    Apr 2010

    Posted 21 Jun 2011 Link to this post

    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
Back to Top
UI for ASP.NET Ajax is Ready for VS 2017