Get 'PART_Filter1ContentControl' control to modifiy the behavior by enum item source

3 posts, 0 answers
  1. Tobias
    Tobias avatar
    28 posts
    Member since:
    Jun 2013

    Posted 13 Aug 2013 Link to this post

    Hi,
    my problem in short: I use the RadGridView inclusive the default filtering control with the Windows8 theme. Everything works perfect except if the column contains an enum.

    Due to the fact, that we use the [Description] Annotation as translation key holder, the dropdown list will display the label instead of the translated value.

    My first thought: No problem!

    I created a custom filter control which overrides parts of the telerik filtering control. This works really good (Apply filter closes popup).

    But now I have a problem. I will access the PART_Filter1ContentControl control to modify the itemsource. This fails everytime with a 'null' value.

    Folowing code is in use:
     public class DefaultFilterControl : FilteringControl
        {
            public DefaultFilterControl(GridViewColumn column) : base(column)
            {
     
            }

    // ...
    public override void Prepare(GridViewColumn columnToPrepare)
    {
         base.Prepare(columnToPrepare);

          // Get first placeholder
         var filterInput1 = GetTemplateChild("PART_Filter1ContentControl");

          // Check which type of control filterInput1 is to fill it the 
          // right way with new data.
    }
    }

    Do you have any idea why it fails and most important, how to solve my problem?

    Thanks!

    - Tobias
  2. Tobias
    Tobias avatar
    28 posts
    Member since:
    Jun 2013

    Posted 13 Aug 2013 Link to this post

    Hi,
    I made some progress. I can now access the field.
    First step of my solution was to add a custom Loaded method to the event. Now I can access the control.

    void FilterControl_Loaded(object sender, System.Windows.RoutedEventArgs e)
    {
        var container1 = GetTemplateChild("PART_Filter1ContentControl") as ContentControl;
        var container2 = GetTemplateChild("PART_Filter2ContentControl") as ContentControl;
        if (container1 == null || container2 == null) return;
     
        var firstDropdown = container1.Content as RadComboBox;
        var secondDropDown = container2.Content as RadComboBox;
        if (firstDropdown == null || secondDropDown == null) return;
     
        firstDropdown.ItemsSource = secondDropDown.ItemsSource = Enum.GetValues(currentColumn.DataType);
    }

    The ItemSource is correct but I see just a blank Dropdown with empty entries instead of the localized string.

    Do you have any idea?

    Thanks!
  3. Dimitrina
    Admin
    Dimitrina avatar
    3769 posts

    Posted 16 Aug 2013 Link to this post

    Hello,

    You can check our online documentation on how to customize the default Field Filter Editor subscribing to the FieldFilterEditorCreated event.  You can also check this help article (for RadDataFilter) as you can use a similar approach for the RadGridView.

    Regards,
    Didie
    Telerik
    TRY TELERIK'S NEWEST PRODUCT - EQATEC APPLICATION ANALYTICS for SILVERLIGHT.
    Learn what features your users use (or don't use) in your application. Know your audience. Target it better. Develop wisely.
    Sign up for Free application insights >>
Back to Top