WinUI

Code Examples Upgrade Guide User Guide Demos Support Forums Download
  • Code Examples
  • Upgrade Guide
  • User Guide
  • Demos
  • Support
  • Forums
  • Download
Class GridFilterControl

    Show / Hide Table of Contents

    Class GridFilterControl

    Represents a control that contains the details about how to filter the data in SfDataGrid by using the filter popup in GridFilterControl.

    Inheritance
    System.Object
    GridFilterControl
    Implements
    System.IDisposable
    System.ComponentModel.INotifyPropertyChanged
    Namespace: Syncfusion.UI.Xaml.DataGrid
    Assembly: Syncfusion.Grid.WinUI.dll
    Syntax
    public class GridFilterControl : ContentControl, IDisposable, INotifyPropertyChanged

    Constructors

    GridFilterControl()

    Initializes a new instance of the GridFilterControl class.

    Declaration
    public GridFilterControl()

    Fields

    AdvancedFilterStyleProperty

    Identifies the AdvancedFilterStyle dependency property.

    Declaration
    public static readonly DependencyProperty AdvancedFilterStyleProperty
    Field Value
    Type Description
    Microsoft.UI.Xaml.DependencyProperty
    Remarks

    The identifier for the AdvancedFilterStyle dependency property.

    AllowBlankFiltersProperty

    Identifies the AllowBlankFilters dependency property.

    Declaration
    public static readonly DependencyProperty AllowBlankFiltersProperty
    Field Value
    Type Description
    Microsoft.UI.Xaml.DependencyProperty
    Remarks

    The identifier for the AllowBlankFilters dependency property.

    AscendingSortStringProperty

    Identifies the AscendingSortString dependency property.

    Declaration
    public static readonly DependencyProperty AscendingSortStringProperty
    Field Value
    Type Description
    Microsoft.UI.Xaml.DependencyProperty
    Remarks

    The identifier for the AscendingSortString dependency property.

    CheckboxFilterStyleProperty

    Identifies the CheckboxFilterStyle dependency property.

    Declaration
    public static readonly DependencyProperty CheckboxFilterStyleProperty
    Field Value
    Type Description
    Microsoft.UI.Xaml.DependencyProperty
    Remarks

    The identifier for the CheckboxFilterStyle dependency property.

    DescendingSortStringProperty

    Identifies the DescendingSortString dependency property.

    Declaration
    public static readonly DependencyProperty DescendingSortStringProperty
    Field Value
    Type Description
    Microsoft.UI.Xaml.DependencyProperty
    Remarks

    The identifier for the DescendingSortString dependency property.

    FilterColumnTypeProperty

    Identifies the FilterColumnType dependency property.

    Declaration
    public static readonly DependencyProperty FilterColumnTypeProperty
    Field Value
    Type Description
    Microsoft.UI.Xaml.DependencyProperty
    Remarks

    The identifier for the FilterColumnType dependency property.

    FilteredFromProperty

    Identifies the FilteredFrom dependency property.

    Declaration
    public static readonly DependencyProperty FilteredFromProperty
    Field Value
    Type Description
    Microsoft.UI.Xaml.DependencyProperty
    Remarks

    The identifier for the FilteredFrom dependency property.

    FilterModeProperty

    Identifies the FilterMode dependency property.

    Declaration
    public static readonly DependencyProperty FilterModeProperty
    Field Value
    Type Description
    Microsoft.UI.Xaml.DependencyProperty
    Remarks

    The identifier for the FilterMode dependency property.

    FilterPopupHeightProperty

    Identifies the FilterPopupHeight dependency property.

    Declaration
    public static readonly DependencyProperty FilterPopupHeightProperty
    Field Value
    Type Description
    Microsoft.UI.Xaml.DependencyProperty
    Remarks

    The identifier for the FilterPopupHeight dependency property.

    FilterPopupWidthProperty

    Identifies the FilterPopupWidth dependency property.

    Declaration
    public static readonly DependencyProperty FilterPopupWidthProperty
    Field Value
    Type Description
    Microsoft.UI.Xaml.DependencyProperty
    Remarks

    The identifier for the FilterPopupWidth dependency property.

    HorizontalOffsetProperty

    Identifies the HorizontalOffset dependency property.

    Declaration
    public static readonly DependencyProperty HorizontalOffsetProperty
    Field Value
    Type Description
    Microsoft.UI.Xaml.DependencyProperty
    Remarks

    The identifier for the HorizontalOffset dependency property.

    ImmediateUpdateColumnFilterProperty

    Identifies the ImmediateUpdateColumnFilter dependency property.

    Declaration
    public static readonly DependencyProperty ImmediateUpdateColumnFilterProperty
    Field Value
    Type Description
    Microsoft.UI.Xaml.DependencyProperty
    Remarks

    The identifier for the ImmediateUpdateColumnFilter dependency property.

    IsAdvancedFilterVisibleProperty

    Identifies the IsAdvancedFilterVisible dependency property.

    Declaration
    public static readonly DependencyProperty IsAdvancedFilterVisibleProperty
    Field Value
    Type Description
    Microsoft.UI.Xaml.DependencyProperty
    Remarks

    The identifier for the IsAdvancedFilterVisible dependency property.

    IsOpenProperty

    Identifies the IsOpen dependency property.

    Declaration
    public static readonly DependencyProperty IsOpenProperty
    Field Value
    Type Description
    Microsoft.UI.Xaml.DependencyProperty
    Remarks

    The identifier for the IsOpen dependency property.

    ResizingThumbVisibilityProperty

    Identifies the ResizingThumbVisibility dependency property.

    Declaration
    public static readonly DependencyProperty ResizingThumbVisibilityProperty
    Field Value
    Type Description
    Microsoft.UI.Xaml.DependencyProperty
    Remarks

    The identifier for the ResizingThumbVisibility dependency property.

    SortOptionVisibilityProperty

    Identifies the SortOptionVisibility dependency property.

    Declaration
    public static readonly DependencyProperty SortOptionVisibilityProperty
    Field Value
    Type Description
    Microsoft.UI.Xaml.DependencyProperty
    Remarks

    The identifier for the SortOptionVisibility dependency property.

    VerticalOffsetProperty

    Identifies the VerticalOffset dependency property.

    Declaration
    public static readonly DependencyProperty VerticalOffsetProperty
    Field Value
    Type Description
    Microsoft.UI.Xaml.DependencyProperty
    Remarks

    The identifier for the VerticalOffset dependency property.

    Properties

    AdvancedFilterStyle

    Gets or sets the style that is applied to the AdvancedFilterControl.

    Declaration
    public Style AdvancedFilterStyle { get; set; }
    Property Value
    Type Description
    Microsoft.UI.Xaml.Style

    The style which is applied to the AdvancedFilterControl.The default value is null.

    Remarks

    To define the Microsoft.UI.Xaml.Style for an AdvancedFilter, then you should specify the TargetType as AdvancedFilterControl.

    Examples
    <Grid.Resources>
        <Style x:Key="advancedfilterstyleforOrderID" BasedOn="{StaticResource AdvancedFilterControlStyle}" TargetType="dataGrid:AdvancedFilterControl">
            <Setter Property="CanGenerateUniqueItems" Value="False" />
        </Style>
        <Style x:Key="popupstyleforOrderID" BasedOn="{StaticResource GridFilterControlStyle}" TargetType="dataGrid:GridFilterControl">
            <Setter Property="FilterMode" Value="Both" />
            <Setter Property="AdvancedFilterStyle" Value="{StaticResource advancedfilterstyleforOrderID}" />
        </Style>
    </Grid.Resources>
    <dataGrid:SfDataGrid ItemsSource = "{Binding Orders}"  AutoGenerateColumns="False">
        <dataGrid:SfDataGrid.Columns>
            <dataGrid:GridTextColumn MappingName = "OrderID" FilterPopupStyle="{StaticResource popupstyleforOrderID}" AllowFiltering="True"/>
        </dataGrid:SfDataGrid.Columns>
    </dataGrid:SfDataGrid>

    AdvancedFilterType

    Gets or sets which type of AdvancedFilter is loaded to the GridFilterControl.

    Declaration
    public AdvancedFilterType AdvancedFilterType { get; set; }
    Property Value
    Type Description
    AdvancedFilterType

    One of the AdvancedFilterType enumeration that specifies which Advanced filter type needs to be loaded. The default value is TextFilter.

    AllowBlankFilters

    Gets or sets a value indicating whether to allow the blank filters.

    Declaration
    public bool AllowBlankFilters { get; set; }
    Property Value
    Type Description
    System.Boolean

    The default value is true.

    Remarks

    In CheckboxFilterControl you can filter the null values by using the Blanks checkbox. You can filter the Null and NotNull values from the underlying data source by using this property in AdvancedFilterControl.

    AscendingSortString

    Gets or sets the text content to the AscendingSortButton in GridFilterControl.

    Declaration
    public string AscendingSortString { get; set; }
    Property Value
    Type Description
    System.String

    A string that specifies the AscendingSortString of GridFilterControl. The default value is string.Empty.

    Remarks

    The value of AscendingSortString is updated from GridLocalizationResources by using the key SortStringAscending.

    Examples
    this.sfDataGrid.FilterItemsPopulating += sfDataGrid_FilterItemsPopulating;
    
    void sfDdataGrid_FilterItemsPopulating(object sender, Syncfusion.UI.Xaml.Grid.GridFilterItemsPopulatingEventArgs e)
    {
         if (e.Column.MappingName == "OrderID")
         {
            e.FilterControl.AscendingSortString = GridLocalizationResourceAccessor.Instance.GetLocalizedStringResource("SortStringAscending");
            e.FilterControl.DescendingSortString = GridLocalizationResourceAccessor.Instance.GetLocalizedStringResource("SortStringDescending"); 
         }
    }

    CheckboxFilterStyle

    Gets or sets the style that is applied to the CheckboxFilterControl.

    Declaration
    public Style CheckboxFilterStyle { get; set; }
    Property Value
    Type Description
    Microsoft.UI.Xaml.Style

    The style which is applied to the CheckboxFilterControl. The default value is null.

    Remarks

    To define a Microsoft.UI.Xaml.Style for a CheckboxFilter, specify a TargetType of CheckboxFilterControl.

    Examples
    <Grid.Resources>
        <Style x:Key="checkboxfilterstyleforOrderID" BasedOn="{StaticResource CheckboxFilterControlStyle}" TargetType="dataGrid:CheckboxFilterControl">
            <Setter Property="Background" Value="Red" />
        </Style>
        <Style x:Key="popupstyleforOrderID" BasedOn="{StaticResource GridFilterControlStyle}" TargetType="dataGrid:GridFilterControl">
            <Setter Property="CheckboxFilterStyle" Value="{StaticResource checkboxfilterstyleforOrderID}" />
        </Style>
    </Grid.Resources>
    <dataGrid:SfDataGrid ItemsSource = "{Binding Orders}"  AutoGenerateColumns="False">
        <dataGrid:SfDataGrid.Columns>
            <dataGrid:GridTextColumn MappingName = "OrderID" FilterPopupStyle="{StaticResource popupstyleforOrderID}" AllowFiltering="True"/>
        </dataGrid:SfDataGrid.Columns>
    </dataGrid:SfDataGrid>

    DescendingSortString

    Gets or sets the text content to the DescendingSortButton in GridFilterControl.

    Declaration
    public string DescendingSortString { get; set; }
    Property Value
    Type Description
    System.String

    A string that specifies DescendingSortString of GridFilterControl. The default value is string.Empty.

    Remarks

    The value of DescendingSortString is updated from GridLocalizationResources by using the key SortStringDescending.

    FilterColumnType

    Gets or sets a value that indicates the FilterColumnType in GridFilterControl.Which is used to show the text content of the AdvancedFilterButton in GridFilterControl.

    Declaration
    public string FilterColumnType { get; set; }
    Property Value
    Type Description
    System.String

    FilterColumnType is used to show which type of AdvancedFilter is loaded in GridFilterCntrol.The default value of FilterColumnType is TextFilters.

    Remarks

    Whenever the AdvancedFilterType property is changed at that time the FilterColumnType is also gets updated to show the AdvancedFilterType text in AdvancedFilterButton.

    FilteredFrom

    Declaration
    public FilteredFrom FilteredFrom { get; set; }
    Property Value
    Type Description
    FilteredFrom

    FilteredFromVisibility

    Gets or sets the display state of FilteredFromVisibility.

    Declaration
    public Visibility FilteredFromVisibility { get; set; }
    Property Value
    Type Description
    Microsoft.UI.Xaml.Visibility

    FilterMode

    Gets or sets a value that specifies the FilterMode in GridFilterControl.

    Declaration
    public FilterMode FilterMode { get; set; }
    Property Value
    Type Description
    FilterMode

    One of the FilterMode enumeration that specifies the FilterMode in SfDataGrid. The default value of the filter mode is Both.

    Examples
    <Grid.Resources>
        <Style TargetType="dataGrid:GridFilterControl" x:Key="gridFilterControlStyle">
            <Setter Property="FilterMode" Value="AdvancedFilter"/>
        </Style>
    </Grid.Resources>
    <dataGrid:SfDataGrid x:Name="sfDataGrid"
                         FilterPopupStyle="{StaticResource  gridFilterControlStyle}"                
                         ItemsSource="{Binding Orders}"/>

    FilterPopupHeight

    Gets or sets the height for the filter popup.

    Declaration
    public double FilterPopupHeight { get; set; }
    Property Value
    Type Description
    System.Double

    The default value is 450.00d

    Examples
    <Grid.Resources>
        <Style TargetType="dataGrid:GridFilterControl" x:Key="gridFilterControlStyle">
            <Setter Property="FilterPopupHeight" Value="300"/>
            <Setter Property="FilterPopupWidth" Value="250"/>
        </Style>
    </Grid.Resources>
    <dataGrid:SfDataGrid x:Name="sfDataGrid"
                         FilterPopupStyle="{StaticResource  gridFilterControlStyle}"                
                         ItemsSource="{Binding Orders}"/>

    FilterPopupWidth

    Gets or sets width for filter popup.

    Declaration
    public double FilterPopupWidth { get; set; }
    Property Value
    Type Description
    System.Double

    The default value is 300.00d

    Examples
    <Grid.Resources>
        <Style TargetType="dataGrid:GridFilterControl" x:Key="gridFilterControlStyle">
            <Setter Property="FilterPopupHeight" Value="300"/>
            <Setter Property="FilterPopupWidth" Value="250"/>
        </Style>
    </Grid.Resources>
    <dataGrid:SfDataGrid x:Name="sfDataGrid"
                         FilterPopupStyle="{StaticResource  gridFilterControlStyle}"                
                         ItemsSource="{Binding Orders}"/>

    HorizontalOffset

    Gets or sets HorizontalOffset for the filter popup.

    Declaration
    public double HorizontalOffset { get; set; }
    Property Value
    Type Description
    System.Double

    The default value is 0d

    ImmediateUpdateColumnFilter

    Gets or sets a value that indicates the ImmediateUpdateColumnFilter.

    Declaration
    public bool ImmediateUpdateColumnFilter { get; set; }
    Property Value
    Type Description
    System.Boolean

    The default value is false.

    Remarks

    You can filter the data immediately from the filter popup. For example you can filter the data from CheckboxFilterControl by check and uncheck the checkbox items. And DoneButton will be shown instead of OkButton,CancelButton in the filter popup while enable the ImmediateUpdateColumnFilter.

    IsAdvancedFilterVisible

    Gets or sets a value that indicates whether the AdvancedFilter is visible or not.

    Declaration
    public bool IsAdvancedFilterVisible { get; set; }
    Property Value
    Type Description
    System.Boolean

    true if AdvancedFilter is visible; otherwise,false. The default value is false.

    IsOpen

    Gets or sets a value that indicates whether the filter popup is opened or not.

    Declaration
    public bool IsOpen { get; set; }
    Property Value
    Type Description
    System.Boolean

    true if the filter popup is opened; otherwise, false. The default value is false.

    ResizingThumbVisibility

    Gets or sets a value that indicates the ResizingThumb Visibility.

    Declaration
    public Visibility ResizingThumbVisibility { get; set; }
    Property Value
    Type Description
    Microsoft.UI.Xaml.Visibility

    One of the Microsoft.UI.Xaml.Visibility enumeration that specifies the visibility of ResizingThumb. The default value of ResizingThumb Visibility is Microsoft.UI.Xaml.Visibility.Visible.

    SortOptionVisibility

    Gets or sets a value that indicates the SortOptionVisibility.

    Declaration
    public Visibility SortOptionVisibility { get; set; }
    Property Value
    Type Description
    Microsoft.UI.Xaml.Visibility

    One of the Microsoft.UI.Xaml.Visibility enumeration that specifies the visibility of SortOption. The default value of SortOption Visibility is Microsoft.UI.Xaml.Visibility.Visible.

    Examples
    <Grid.Resources>
        <Style TargetType="dataGrid:GridFilterControl" x:Key="gridFilterControlStyle">
            <Setter Property = "SortOptionVisibility" Value="Collapsed"/>
        </Style>
    </Grid.Resources>
    <dataGrid:SfDataGrid x:Name="sfDataGrid"
                         FilterPopupStyle="{StaticResource  gridFilterControlStyle}"                
                         ItemsSource="{Binding Orders}"/>

    VerticalOffset

    Gets or sets the VerticalOffset for filter popup.

    Declaration
    public double VerticalOffset { get; set; }
    Property Value
    Type Description
    System.Double

    The default value is 0d

    Methods

    Dispose()

    Disposes all the resources used by the GridFilterControl class.

    Declaration
    public void Dispose()

    Dispose(Boolean)

    Disposes all the resources used by the GridFilterControl class.

    Declaration
    protected virtual void Dispose(bool isDisposing)
    Parameters
    Type Name Description
    System.Boolean isDisposing

    Indicates whether the call is from Dispose method or from a finalizer.

    GetFormattedString(Object)

    Gets the formatted string for the actual value of the corresponding record in the filter column.

    Declaration
    public string GetFormattedString(object item)
    Parameters
    Type Name Description
    System.Object item

    Which holds the actual value of the corresponding record in the filter column.

    Returns
    Type Description
    System.String

    Returns the formatted string for the actual value of the corresponding record in the filter column.

    OnApplyTemplate()

    Builds the visual tree for the GridFilterControl when a new template is applied.

    Declaration
    protected override void OnApplyTemplate()

    OnKeyDown(KeyRoutedEventArgs)

    Called before the KeyDown event occurs.

    Declaration
    protected override void OnKeyDown(KeyRoutedEventArgs e)
    Parameters
    Type Name Description
    Microsoft.UI.Xaml.Input.KeyRoutedEventArgs e

    The Microsoft.UI.Xaml.Input.KeyRoutedEventArgs contains the event data.

    OnPointerMoved(PointerRoutedEventArgs)

    Called before the PointerMoved event occurs.

    Declaration
    protected override void OnPointerMoved(PointerRoutedEventArgs e)
    Parameters
    Type Name Description
    Microsoft.UI.Xaml.Input.PointerRoutedEventArgs e

    The Microsoft.UI.Xaml.Input.PointerRoutedEventArgs instance that contains the event data.

    OnPropertyChanged(String)

    Invoked when the PropertyChanged event occurs.

    Declaration
    public void OnPropertyChanged(string propertyName)
    Parameters
    Type Name Description
    System.String propertyName

    The corresponding property name.

    SetColumnDataType(Type)

    Sets the filtered column dataType to the AdvancedFilterControl.Which is used to validate the entered value in the Textbox or ComboBox in the AdvancedFilterControl while applying the filter.

    Declaration
    public void SetColumnDataType(Type type)
    Parameters
    Type Name Description
    System.Type type

    It specifies the Type and it will be a string or DateTime or object.

    Examples
    this.sfDataGrid.FilterItemsPopulating += sfDataGrid_FilterItemsPopulating;
    
    void sfDdataGrid_FilterItemsPopulating(object sender, Syncfusion.UI.Xaml.Grid.GridFilterItemsPopulatingEventArgs e)
    {
         if (e.Column.MappingName == "OrderID")
         {
            e.FilterControl.AdvancedFilterType = AdvancedFilterType.TextFilter;
            e.FilterControl.SetColumnDataType(typeof(string));
         }
    }

    Events

    PropertyChanged

    Occurs when a property value changes.

    Declaration
    public event PropertyChangedEventHandler PropertyChanged
    Event Type
    Type Description
    System.ComponentModel.PropertyChangedEventHandler

    Implements

    System.IDisposable
    System.ComponentModel.INotifyPropertyChanged
    Back to top Generated by DocFX
    Copyright © 2001 - 2023 Syncfusion Inc. All Rights Reserved