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

Reset Filter Programmatically

2 Answers 295 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Jan Hesselgren
Top achievements
Rank 1
Jan Hesselgren asked on 30 May 2008, 11:47 AM
Hello, I have a quick question:

I am using a single RadGridView for displaying various List<> of custom objects. This works well until I set a filter for one of the columns, and a column with that name doesn't exist on the new bound List<>

The exception is thrown just as I set Datasource="NewCustomList"

I have tried to iterate through the columns for clearing the filter, and I've also tried Clear() the columns, but this didn't help.

How can I reset the filter programmatically?

Thanks

2 Answers, 1 is accepted

Sort by
0
Accepted
Jack
Telerik team
answered on 30 May 2008, 04:24 PM
Hi Jan Hesselgren,

Thank you for this question.

Many developers wanted to persist the state of the filter expressions when changing the data source. Because of this, they aren't cleared when a new data source is set. To remove the old filter expressions, call the Clear method of the FilterExpressions collection.

Refer to the following code snippet:

this.radGridView1.MasterGridViewTemplate.FilterExpressions.Clear(); 

I hope this helps. Should you have other questions, do not hesitate to contact me again.

All the best,
Jack
the Telerik team

Instantly find answers to your questions at the new Telerik Support Center
0
Jan Hesselgren
Top achievements
Rank 1
answered on 02 Jun 2008, 07:33 AM
This worked great, thank you very much!
Tags
GridView
Asked by
Jan Hesselgren
Top achievements
Rank 1
Answers by
Jack
Telerik team
Jan Hesselgren
Top achievements
Rank 1
Share this question
or