How to hide "Clear Filter" option from filter in RadGridView?

5 posts, 0 answers
  1. Ivan
    Ivan avatar
    3 posts
    Member since:
    Feb 2015

    Posted 24 Feb 2015 Link to this post

    Hi,

    Is there any way to hide option "Clear Filter" in RadGridView? I use FilteringMode.FilterRow. I know that we have available filter operators in FilterOperatorsLoading event, but this collection doesn't have option "Clear Filter". Mayve we have another way to hide this option in filter?


  2. Stefan
    Admin
    Stefan avatar
    1073 posts

    Posted 26 Feb 2015 Link to this post

    Hello Ivan,

    In order to customize the default Filter editor pop up menu, please refer to the Styling the FilteringControl documentation article.You may need to remote the element with x:Name PART_ClearFilterButton as part of this template. You may apply this style to all RadGridView columns via defining implicit style. Another option would be to set this style via FilteringControlStyle property of the column. 

    I hope that this helps.


    Best Regards,
    Stefan
    Telerik
     

    Check out the Telerik Platform - the only platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native mobile apps.

     
  3. Ivan
    Ivan avatar
    3 posts
    Member since:
    Feb 2015

    Posted 05 Mar 2015 in reply to Stefan Link to this post

    Thanks Stefan,

    But I want to remove option "Clear Filter" which is a part of the FieldFilterControl RadDropDownButton, not the FilteringControl. http://docs.telerik.com/devtools/wpf/controls/radgridview/styles-and-templates/styling-filterrow, please look at code snippet:

    <telerik:RadDropDownButton.DropDownContent>
    <ListBox x:Name="PART_FilterOperatorsListBox"
    ItemsSource="{Binding AvailableOperatorViewModels}"
    SelectedItem="{Binding SelectedOperatorViewModel, Mode=TwoWay}"
    telerik:StyleManager.Theme="{StaticResource Theme}"/>
    </telerik:RadDropDownButton.DropDownContent>

    I suppose "Clear Filter" is generated inside of AvailableOperatorViewModels. How to hide this option from UI ? Is it possible to do from styling?

  4. Stefan
    Admin
    Stefan avatar
    1073 posts

    Posted 09 Mar 2015 Link to this post

    Hi Ivan,

    Thank you for clarifying this.

    In order to achieve this customization you can follow these steps:

    1.   Define a Converter, which will be applied to the ItemSource collection of the ListBox within RadDropDownButton Content. In the "Convert" method simply return the ItemSource collection without the first element, as this would always be the "ClearFilter" Button:
    public object Convert(object value, Type targetType,
        object parameter, System.Globalization.CultureInfo culture)
    {
        var collection = value as IEnumerable<object>;
     
        if (collection != null)
        {
            return collection.Skip(1);
        }
     
        return null;
    }

    2.   Define the Converter in Telerik.Windows.GridView.xaml file
    <my:ItemsSourceConverter x:Key="myConverter"/>

    3.   Apply the Converter to the ListBox ItemsSource collection
    <telerik:RadDropDownButton.DropDownContent>
        <ListBox x:Name="PART_FilterOperatorsListBox"
                 ItemsSource="{Binding AvailableOperatorViewModels,
                 Converter={StaticResource myConverter}}"
                 SelectedItem="{Binding SelectedOperatorViewModel, Mode=TwoWay}"/>
    </telerik:RadDropDownButton.DropDownContent>

    I have attached a sample project illustrating the described approach.

    Let me know how this sample works for you.

    Best Regards,
    Stefan
    Telerik
     

    Check out the Telerik Platform - the only platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native mobile apps.

     
  5. Ivan
    Ivan avatar
    3 posts
    Member since:
    Feb 2015

    Posted 11 Mar 2015 in reply to Stefan Link to this post

    It works fine, thank you very much.
Back to Top