Close Filtering Popup on Pressing Filter Button

In order to close filtering Popup on pressing the fitler button, you need to override the OnApplyFilter method of FilteringControl.

A demo on how to achieve the desired behavior is available in our SDK Samples Browser. The demo is labeled "Close Filtering Popup" and can also be found on GitHub - CloseFilteringPopupFilterButton.

Example 1: Overriding OnApplyFilter method

public class MyFilteringControl : FilteringControl 
{ 
    public MyFilteringControl(Telerik.Windows.Controls.GridViewColumn column) : base(column) 
    {          
 
    }         
 
    protected override void OnApplyFilter() 
    { 
        base.OnApplyFilter(); 
 
        var popup = this.ParentOfType<Popup>(); 
        if (popup != null) 
        { 
            popup.IsOpen = false; 
        }            
    } 
} 
Public Class MyFilteringControl 
    Inherits FilteringControl 
    Public Sub New(column As Telerik.Windows.Controls.GridViewColumn) 
 
        MyBase.New(column) 
    End Sub 
 
    Protected Overrides Sub OnApplyFilter() 
        MyBase.OnApplyFilter() 
 
        Dim popup = Me.ParentOfType(Of Popup)() 
        If popup IsNot Nothing Then 
            popup.IsOpen = False 
        End If 
    End Sub 
End Class 

Then you can apply it to a desired column like so:

Example 2: Apply the Custom Filter to the column

this.radGridView.Columns["Name"].FilteringControl = new MyFilteringControl(this.radGridView.Columns["Name"]); 
Me.radGridView.Columns("Name").FilteringControl = New MyFilteringControl(Me.radGridView.Columns("Name")) 

In case you are using NoXaml Binaries and Implicit Styles, you should additionally apply a template. Please refer to the Styling custom controls section. The Style you should apply in XAML then is:

[XAML] Example 3: Style targetting the custom control

<Style TargetType="my:MyFilteringControl" BasedOn="{StaticResource FilteringControlStyle}"/>
In this article
Not finding the help you need? Improve this article