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

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

4 Answers 217 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Ivan
Top achievements
Rank 1
Ivan asked on 24 Feb 2015, 08:01 AM
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?


4 Answers, 1 is accepted

Sort by
0
Stefan
Telerik team
answered on 26 Feb 2015, 05:25 PM
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.

 
0
Ivan
Top achievements
Rank 1
answered on 05 Mar 2015, 06:13 AM
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?

0
Stefan
Telerik team
answered on 09 Mar 2015, 02:36 PM
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.

 
0
Ivan
Top achievements
Rank 1
answered on 11 Mar 2015, 10:37 AM
It works fine, thank you very much.
Tags
GridView
Asked by
Ivan
Top achievements
Rank 1
Answers by
Stefan
Telerik team
Ivan
Top achievements
Rank 1
Share this question
or