Subclassed FilteringControl Not Displaying

6 posts, 1 answers
  1. Russell
    Russell avatar
    9 posts
    Member since:
    Mar 2015

    Posted 18 Mar 2015 Link to this post

    Hi there,

    I've subclassed the FilteringControl in order to hook in to the OnApplyFilter() call.  When I apply this filtering control to my column nothing happens when I click on the filter button in the column header.  When I test it out using the parent FilteringControl class it works fine.

    This is the Xaml...

    <Window x:Class="TestTelerikGrid.MainWindow"
            xmlns:testTelerikGrid="clr-namespace:TestTelerikGrid"
            Title="MainWindow" Height="350" Width="525">
        <Window.Resources>
            <ResourceDictionary>
                <ResourceDictionary.MergedDictionaries>
                    <ResourceDictionary Source="/Telerik.Windows.Themes.Expression_Dark;component/Themes/System.Windows.xaml"/>
                    <ResourceDictionary Source="/Telerik.Windows.Themes.Expression_Dark;component/Themes/Telerik.Windows.Controls.xaml"/>
                    <ResourceDictionary Source="/Telerik.Windows.Themes.Expression_Dark;component/Themes/Telerik.Windows.Controls.Navigation.xaml"/>
                    <ResourceDictionary Source="/Telerik.Windows.Themes.Expression_Dark;component/Themes/Telerik.Windows.Controls.GridView.xaml"/>
                    <ResourceDictionary Source="/Telerik.Windows.Themes.Expression_Dark;component/Themes/Telerik.Windows.Controls.Input.xaml"/>
                    <ResourceDictionary Source="/Telerik.Windows.Themes.Expression_Dark;component/Themes/Telerik.Windows.Controls.Data.xaml"/>
                </ResourceDictionary.MergedDictionaries>
            </ResourceDictionary>
        </Window.Resources>
        <Grid>
            <telerik:RadGridView x:Name="radGridView" AutoGenerateColumns="False">
                <telerik:RadGridView.Columns>
                    <telerik:GridViewDataColumn DataMemberBinding="{Binding FirstName}">
                        <telerik:GridViewDataColumn.FilteringControl>
                            <testTelerikGrid:BasicFilteringControl />
                        </telerik:GridViewDataColumn.FilteringControl>
                    </telerik:GridViewDataColumn>
                </telerik:RadGridView.Columns>
            </telerik:RadGridView>
        </Grid>
    </Window>


    This is the code behind...

    using System.Windows;
    using Telerik.Windows.Controls.GridView;
     
    namespace TestTelerikGrid
    {
      /// <summary>
      /// Interaction logic for MainWindow.xaml
      /// </summary>
      public partial class MainWindow : Window
      {
        public MainWindow()
        {
          InitializeComponent();
          radGridView.ItemsSource = EmployeeService.GetEmployees();
        }
      }
     
      public class BasicFilteringControl : FilteringControl
      {
      }
    }


    Then this is the data generation code...

    using System.Collections.ObjectModel;
     
    namespace TestTelerikGrid
    {
      public class Employee
      {
        public string FirstName
        {
          get;
          set;
        }
        public string LastName
        {
          get;
          set;
        }
        public int Age
        {
          get;
          set;
        }
        public bool IsMarried
        {
          get;
          set;
        }
      }
     
      public class EmployeeService
      {
        public static ObservableCollection<Employee> GetEmployees()
        {
          ObservableCollection<Employee> employees = new ObservableCollection<Employee>();
          Employee employee = new Employee();
          employee.FirstName = "Maria";
          employee.LastName = "Anders";
          employee.IsMarried = true;
          employee.Age = 24;
          employees.Add(employee);
          employee = new Employee();
          employee.FirstName = "Ana";
          employee.LastName = "Trujillo";
          employee.IsMarried = true;
          employee.Age = 44;
          employees.Add(employee);
          employee = new Employee();
          employee.FirstName = "Antonio";
          employee.LastName = "Moreno";
          employee.IsMarried = true;
          employee.Age = 33;
          employees.Add(employee);
          employee = new Employee();
          employee.FirstName = "Thomas";
          employee.LastName = "Hardy";
          employee.IsMarried = false;
          employee.Age = 13;
          employees.Add(employee);
          employee = new Employee();
          employee.FirstName = "Hanna";
          employee.LastName = "Moos";
          employee.IsMarried = false;
          employee.Age = 28;
          employees.Add(employee);
          employee = new Employee();
          employee.FirstName = "Frederique";
          employee.LastName = "Citeaux";
          employee.IsMarried = true;
          employee.Age = 67;
          employees.Add(employee);
          employee = new Employee();
          employee.FirstName = "Martin";
          employee.LastName = "Sommer";
          employee.IsMarried = false;
          employee.Age = 22;
          employees.Add(employee);
          employee = new Employee();
          employee.FirstName = "Laurence";
          employee.LastName = "Lebihan";
          employee.IsMarried = false;
          employee.Age = 32;
          employees.Add(employee);
          employee = new Employee();
          employee.FirstName = "Elizabeth";
          employee.LastName = "Lincoln";
          employee.IsMarried = false;
          employee.Age = 9;
          employees.Add(employee);
          employee = new Employee();
          employee.FirstName = "Victoria";
          employee.LastName = "Ashworth";
          employee.IsMarried = true;
          employee.Age = 29;
          employees.Add(employee);
          return employees;
        }
      }
    }

    I'm running .Net 4.5 and Telerik 2015.1 noxaml binaries (although I've had the same issue with 2014.3 Telerik noxaml binaries too).  I suspect I'm doing something wrong here as this basic action doesn't appear to be working for me.

    Thanks in advance for your help.
    Russell
  2. Russell
    Russell avatar
    9 posts
    Member since:
    Mar 2015

    Posted 18 Mar 2015 in reply to Russell Link to this post

    Not sure if it helps, but calling this doesn't cause the drop down to open either...

    radGridView.ChildrenOfType<FilteringDropDown>().First().IsDropDownOpen = true;
  3. Dimitrina
    Admin
    Dimitrina avatar
    3769 posts

    Posted 19 Mar 2015 Link to this post

    Hi,

    I can see that you have an empty BasicFilteringControl. Would you please check the article on Custom Filtering Controls that  explains the feature enabling the developer to build any kind of custom filtering logic and UI?

    Regards,
    Dimitrina
    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.

     
  4. Russell
    Russell avatar
    9 posts
    Member since:
    Mar 2015

    Posted 19 Mar 2015 in reply to Dimitrina Link to this post

    So is the example in this article no longer supported...

    http://docs.telerik.com/devtools/wpf/controls/radgridview/filtering/how-to/howto-close-filtering-popup-on-pressing-the-filter-button.html

    ?

    Thanks
    Russell
  5. Answer
    Dimitrina
    Admin
    Dimitrina avatar
    3769 posts

    Posted 20 Mar 2015 Link to this post

    Hello Russell,

    As it turns out, this problem is because there is not a template set for the custom style when NoXaml binaries are merged. 
    You should additionally apply the following logic:
    class MyFilteringControl : FilteringControl
    {
        public MyFilteringControl(GridViewColumn column) : base(column)
        {
            this.DefaultStyleKey=typeof(MyFilteringControl);
        }
        ...
    }

    Including a style targeting the new type:
    <Grid.Resources>
        <Style TargetType="my:MyFilteringControl" BasedOn="{StaticResource FilteringControlStyle}"/>
    </Grid.Resources>
     
    Let me know how this works for you.

    Regards,
    Dimitrina
    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.

     
  6. Russell
    Russell avatar
    9 posts
    Member since:
    Mar 2015

    Posted 25 Mar 2015 Link to this post

    Perfect, spot on, thanks Dimitrina! :-)
Back to Top