Removing items from ASP.Net Filter

2 posts, 0 answers
  1. Munish
    Munish avatar
    2 posts
    Member since:
    Jan 2013

    Posted 30 Jan 2013 Link to this post

    Hello All

    I am using telerik filter control ( I have a requirement where i would like to remove items from filters like let suppose i am filtering on order table it displays orderid, ordername and ordertype the same will be displayed in result grid, it is working. Now if i remove items from grid(columns) like i remove orderid from filters also. I can remove item from grid however can anyone help me how can i remove the item from the filter.

  2. Angel Petrov
    Angel Petrov avatar
    1116 posts

    Posted 07 Feb 2013 Link to this post

    Hi Munish,

    In order to achieve this you would have to find the filter expression with a FieldName matching that of the column. This can be achieved by using this code snippet:
    for (int i = 0; i < RadFilter1.RootGroup.Expressions.Count; i++)
                string filteredField = (RadFilter1.RootGroup.Expressions[i] as RadFilterNonGroupExpression).FieldName;
                int filterExpressionIndex = i;

    Later you can remove the expression by index:
    //remove the filter expression
            RadFilter1.RootGroup.Expressions.Remove(RadFilter1.RootGroup.Expressions[filterExpressionIndex ]);

    All the best,
    Angel Petrov
    the Telerik team
    If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to their blog feed now.
Back to Top