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

Removing items from ASP.Net Filter

1 Answer 53 Views
Filter
This is a migrated thread and some comments may be shown as answers.
Munish
Top achievements
Rank 1
Munish asked on 30 Jan 2013, 11:39 AM
Hello All

I am using telerik asp.net filter control (http://demos.telerik.com/aspnet-ajax/filter/examples/overview/defaultcs.aspx). 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.

Thanks

1 Answer, 1 is accepted

Sort by
0
Angel Petrov
Telerik team
answered on 07 Feb 2013, 08:13 AM
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 ]);
        RadFilter1.RecreateControl();

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.
Tags
Filter
Asked by
Munish
Top achievements
Rank 1
Answers by
Angel Petrov
Telerik team
Share this question
or