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

Programmatic clearing of column filters does not update the filter dialog

1 Answer 114 Views
GridView
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
Anne Lyon
Top achievements
Rank 1
Anne Lyon asked on 28 Dec 2012, 03:29 PM
Hi,

In my Silverlight 4 application (Telerik v 2012.2.607) I programatically loop through all FilterDescriptors for my grid to find if there is a filter set for a given columnName. If so, I remove the FilterDescriptor for that column from the collection. This works fine, the filter is removed from the grid and all rows are displayed. But if then the user opens the Filter Dialog Box (by clicking the column filter icon), the previous filter selection is still displayed. See attached screen shot. It shows there are no filters set (the column header icon is "off") but still the old value is ticked in the Filter Dialog.
How do I clear the selections in the Filter Dialog Box for a column when I have removed the FilterDescriptor for that column in code?

The code to remove the filter descriptor for a given column name is given below:

gridKolName = selCol.ElementValue.ToString();

 

 

foreach (IColumnFilterDescriptor desc in MasterGrid.FilterDescriptors)

 

{

col = (

 

GridViewDataColumn)desc.Column;

 

filterName = col.Header.ToString();

 

 

if (filterName == gridKolName)

 

{

MasterGrid.FilterDescriptors.Remove(desc);

 

 

break;

 

}

}



1 Answer, 1 is accepted

Sort by
0
Rossen Hristov
Telerik team
answered on 29 Dec 2012, 09:06 AM
Hi,

Please, take a look at this article for the proper way to clear column filters. You should do something like this:

this.radGridView.FilterDescriptors.SuspendNotifications();
foreach (Telerik.Windows.Controls.GridViewColumn column in this.radGridView.Columns)
{
    column.ClearFilters();
}
this.radGridView.FilterDescriptors.ResumeNotifications();

I hope this helps.

Regards,
Rossen Hristov
the Telerik team

Explore the entire Telerik portfolio by downloading Telerik DevCraft Ultimate.

Tags
GridView
Asked by
Anne Lyon
Top achievements
Rank 1
Answers by
Rossen Hristov
Telerik team
Share this question
or