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

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

2 Answers 96 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Tobias
Top achievements
Rank 1
Tobias asked on 13 Aug 2013, 05:44 AM
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 Answers, 1 is accepted

Sort by
0
Tobias
Top achievements
Rank 1
answered on 13 Aug 2013, 06:29 AM
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!
0
Dimitrina
Telerik team
answered on 16 Aug 2013, 09:01 AM
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 >>
Tags
GridView
Asked by
Tobias
Top achievements
Rank 1
Answers by
Tobias
Top achievements
Rank 1
Dimitrina
Telerik team
Share this question
or