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

Localizing FilteringControl with different resources

3 Answers 97 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Abdelkader Belkadi
Top achievements
Rank 1
Abdelkader Belkadi asked on 08 Sep 2010, 03:31 PM
Hello,
I wanted to change the filter labels and localize them,
I used the LocalizationManager and it works fine,
However for three type of data, I'd like to display three type of labels, which are (numerics, DateTime, and strings)
I couldn't manage to localize these different columns with different resource files,
So went through the following solutions  :
Solution I
created a new style/Template for the FilteringControl and applied this style to the control as shown bellow:
<ResourceDictionary>

<local:ImageTypeConverter x:Key="imageTypeConverter"></local:ImageTypeConverter><local:ContainsKeywordsIconConverter x:Key="containsKeywordsIconConverter"></local:ContainsKeywordsIconConverter> <ResourceDictionary.MergedDictionaries>

 

 

 

<ResourceDictionary Source="../Themes/Resources/Dictionaries/FilteringControlStyle.xaml"/>

 

</ResourceDictionary.MergedDictionaries>

 

</ResourceDictionary>

 

 

<telerik:GridViewDataColumn Header="Date" UniqueName="Date"   DataMemberBinding="{Binding DateCreation}" HeaderCellStyle="{StaticResource CustomHeaderCell}">

  

 

                  <telerik:GridViewDataColumn.FilteringControl >
                      <telerik:FilteringControl ></telerik:FilteringControl>
                  </telerik:GridViewDataColumn.FilteringControl>
              </telerik:GridViewDataColumn>
Doing this, the PART_DistinctValuesList is not   filled up with any data, neither the filter expressions is.
Solution II
Created a new control by copy/pasting the previouse style definition of the FilteringControl as shown bellow
 

<Border Margin="0,2,0,0" BorderBrush="#FF848484" BorderThickness="1,1,1,1" CornerRadius="1">

 

<Border Background="#FFE4E4E4" BorderBrush="White" BorderThickness="1">
<StackPanel HorizontalAlignment="Stretch" Margin="5,5,5,5" MaxWidth="350" MinWidth="200" VerticalAlignment="Stretch">

 

<StackPanel x:Name="PART_DistinctFilter" Visibility="Visible">

 

........Up to the end,

Of course, my usercontrol implements  IFilteringControl as stated in the help tutorial
But here I must redefine all actions of the controls, (Onfilter, onclear, selectAll and so on...)

Is there some missing thing I could add in either one of both solutions to overcome the corresponding shortcut ? or  I must continue in the second solution by codding all necessary actions ? which seems to be a bit heavy for just localizing differents columns filters with different resources files,

Thanks in advance for your help,
Abdelkader

 


 

 

 

3 Answers, 1 is accepted

Sort by
0
Maya
Telerik team
answered on 13 Sep 2010, 01:31 PM
Hi Abdelkader Belkadi,

In order to meet your requirements for localizing each column's filter, you need to create your own custom filtering control and expose a new property, for example, that is reponsible for setting the appropriate Resource file. 
The default filtering control provides the possiblitity of changing the localized strings, but it will be reflected by the whole grid, meaning all the columns.
 

Kind regards,
Maya
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
0
Abdelkader Belkadi
Top achievements
Rank 1
answered on 13 Sep 2010, 02:48 PM
Hi Maya,

ok fine, in this case, would it be possible to style the filtercontrol instead of recreating them, and apply these different filter's styles or control templates for the tree different columns ?
the idea is still to avoid implementing the filter actions which are already implemented natively,

FYI : I styled the filtercontro and applied the style on a filtercontrol, but no data was bound to the filter... did I miss a small codesnipet, or shall I implement the binding and actions handlers ?

Best Regards,
Abdelkader
0
Maya
Telerik team
answered on 14 Sep 2010, 01:34 PM
Hi Abdelkader Belkadi,

In order for you to achieve your requirement you need to follow those steps:
1. Get the Template of the Filtering Control.
2. Find the RadComboBox elements inside. Each of them has ItemTemplate property set to a separate StaticResource. For example:

<input:RadComboBox x:Name="PART_Filter2ComboBox"                                                               
            Margin="0,2"                                        
            telerik:StyleManager.Theme="{StaticResource Theme}"                                         
            ItemTemplate="{StaticResource ActionTemplate}"                                                                                     ItemsSource="{Binding AvailableActions}"                                                              
            SelectedItem="{Binding Filter2.Operator, Mode=TwoWay}" />

<DataTemplate x:Key="ActionTemplate">
    <TextBlock Text="{Binding Converter={StaticResource            
                          FilterOperatorConverter}}"
 />
</DataTemplate>

3. The Converter defined here is responsible for the strings inside and you need to create a custom converter that meets your requirements.
4. Define separate styles and set them to your columns.
 

Regards,
Maya
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
Tags
GridView
Asked by
Abdelkader Belkadi
Top achievements
Rank 1
Answers by
Maya
Telerik team
Abdelkader Belkadi
Top achievements
Rank 1
Share this question
or