RadGridView - Disable Filter on a Column (not hide)

2 posts, 0 answers
  1. Karlo
    Karlo avatar
    3 posts
    Member since:
    May 2012

    Posted 21 Dec 2016 Link to this post

    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

     

  2. Dilyan Traykov
    Admin
    Dilyan Traykov avatar
    1173 posts

    Posted 22 Dec 2016 Link to this post

    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.
Back to Top