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

RadGridView - Disable Filter on a Column (not hide)

1 Answer 207 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Karlo
Top achievements
Rank 1
Karlo asked on 22 Dec 2016, 01:13 AM

I just want to disable (grayed-out, un-clickable) the "funnel" icon of the filter on the radgridview header and not HIDE it.

Is there easy way to do it without creating a custom filter?

 

Cheers

 

1 Answer, 1 is accepted

Sort by
0
Dilyan Traykov
Telerik team
answered on 22 Dec 2016, 03:58 PM
Hello Karlo,

In order to achieve the desired result, you can edit the control template of the GridViewHeaderCell element and make use of its FilteringUIVisibility property. What you can do is to define the FilteringDropDown inside of the control template like so (for the Office_Black theme):

<grid:FilteringDropDown x:Name="PART_DistinctFilterControl" Grid.Column="1" Opacity="{TemplateBinding FilteringUIVisibility, Converter={StaticResource VisibilityToOpacityConverter}}" IsEnabled="{TemplateBinding FilteringUIVisibility, Converter={StaticResource VisibilityToBooleanConverter}}" Margin="0 0 4 0"/>

Here are the two converters:

public class VisibilityToBooleanConverter : IValueConverter
{
    public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
    {
        return (Visibility) value == Visibility.Visible;
    }
 
    public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
    {
        throw new NotImplementedException();
    }
}
public class VisibilityToOpacityConverter : IValueConverter
{
    public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
    {
        return (Visibility)value == Visibility.Visible ? 1 : 0.5;
    }
 
    public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
    {
        throw new NotImplementedException();
    }
}

Additionally, you can apply the custom control template only to specific columns by using their HeaderCellStyle property.

Please let me know if this would work for you.

Regards,
Dilyan Traykov
Telerik by Progress
Want to extend the target reach of your WPF applications, leveraging iOS, Android, and UWP? Try UI for Xamarin, a suite of polished and feature-rich components for the Xamarin framework, which allow you to write beautiful native mobile apps using a single shared C# codebase.
Tags
GridView
Asked by
Karlo
Top achievements
Rank 1
Answers by
Dilyan Traykov
Telerik team
Share this question
or