How to traverse each group?

2 posts, 0 answers
  1. Vatsal
    Vatsal avatar
    26 posts
    Member since:
    Oct 2010

    Posted 28 Nov 2012 Link to this post

    Hi,

    I am using radfilter control to filter my grid. I want to traverse each group and filter of each group programmatically. Currently I am using "RadFilter1.RootGroup.Expressions" method but it shows only root group and it's filter. How do I traverse other group and it's filter. Please help.

    Thanks
  2. Alex
    Alex avatar
    31 posts
    Member since:
    Jun 2011

    Posted 02 Dec 2012 Link to this post

    Not sure that this is the best or intended way, but seems to be working for me.


    protected string TraverseFilterGroups(Telerik.Web.UI.RadFilterGroupExpressionItem groupItem)
    {
        string translatedExpression = String.Empty;
     
        foreach(var child in groupItem.ChildItems)
        {
            if (child is Telerik.Web.UI.RadFilterGroupExpressionItem)
                translatedExpression += " ( " + TraverseFilterGroups((Telerik.Web.UI.RadFilterGroupExpressionItem)child) + ")";
            else
            {
                Telerik.Web.UI.RadFilterSingleExpressionItem expressionItem = (Telerik.Web.UI.RadFilterSingleExpressionItem)child;
     
                if (expressionItem.Expression.FilterFunction == Telerik.Web.UI.RadFilterFunction.EqualTo)
                {
                    translatedExpression += expressionItem.Expression.FieldName + " = " + ((Telerik.Web.UI.RadFilterEqualToFilterExpression<string>)expressionItem.Expression).Value;
                }
            }
            translatedExpression += " " + groupItem.Expression.GroupOperation.ToString() + " ";
        }
     
        translatedExpression = translatedExpression.Substring(0, translatedExpression.LastIndexOf(' ', translatedExpression.Length-2));
        return translatedExpression;
    }
  3. UI for ASP.NET Ajax is Ready for VS 2017
Back to Top