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

How to localize RadGrid column headers

9 Answers 337 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Abhi Basu
Top achievements
Rank 1
Abhi Basu asked on 03 Sep 2009, 12:28 AM
Attached is the sample code. I would like to read the column header texts from my existing resx file using a binding like - "{Binding Path=StringLibrary.RadGridViewPatients_PatientID, Source={StaticResource LocalizedStrings}}".

<telerikGridView:RadGridView x:Name="RadGridViewPatients" AutoGenerateColumns="False" IsReadOnly="True"
            Grid.Row="2" Margin="8,0,52,49" Grid.Column="1" ColumnBackground="LightBlue" Width="458" Height="306"
            VerticalAlignment="Bottom" MultipleSelect="False" SelectionChanged="RadGridViewPatients_SelectionChanged">
            <telerikGridView:RadGridView.Columns>
                <telerikGridView:GridViewDataColumn HeaderText="" TextAlignment="Center" Width="20">
                    <telerikGridView:GridViewDataColumn.CellTemplate>
                        <DataTemplate>
                            <CheckBox IsEnabled="True"  />
                        </DataTemplate>
                    </telerikGridView:GridViewDataColumn.CellTemplate>
                    <telerikGridView:GridViewDataColumn.CellEditTemplate>
                        <DataTemplate>
                            <CheckBox IsEnabled="True"/>
                        </DataTemplate>
                    </telerikGridView:GridViewDataColumn.CellEditTemplate>
                </telerikGridView:GridViewDataColumn>

                <telerikGridView:GridViewDataColumn Width="50" DataMemberPath="PatientID" HeaderText="ID">
                   
                </telerikGridView:GridViewDataColumn>
                <telerikGridView:GridViewDataColumn Width="100" DataMemberPath="Identifier" HeaderText="Identifier">
                
                </telerikGridView:GridViewDataColumn>
                <telerikGridView:GridViewDataColumn Width="100"  DataMemberPath="FirstName" HeaderText="First Name">
                   
                </telerikGridView:GridViewDataColumn>
                <telerikGridView:GridViewDataColumn Width="100"  DataMemberPath="LastName" HeaderText="Last Name">
                    
                </telerikGridView:GridViewDataColumn>
                <telerikGridView:GridViewDataColumn Width="100" DataMemberPath="PhoneNbr" HeaderText="Number">
                  
                </telerikGridView:GridViewDataColumn>

            </telerikGridView:RadGridView.Columns>

        </telerikGridView:RadGridView>

Thanks.
       

9 Answers, 1 is accepted

Sort by
0
Abhi Basu
Top achievements
Rank 1
answered on 04 Sep 2009, 05:38 PM
Can anyone help me with this? How do I map my non-autogenerated columns to resx file items in the XAML file?

Thanks.
0
Pavel Pavlov
Telerik team
answered on 07 Sep 2009, 12:08 PM
Hi Abhi Basu,

The attached example demonstrates the recoomended way to implement column header localization by reading localized strings from resx files.

Best wishes,
Pavel Pavlov
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
0
Abhi Basu
Top achievements
Rank 1
answered on 08 Sep 2009, 04:44 PM
The example you posted is too simple to demonstrate what I need. Most grids would be populated from a web service call and return a list of some objects. I modified my code as you suggested but I get an exception with loading the grid - "{System.ArgumentException: Value does not fall within the expected range.
   at MS.Internal.XcpImports.CheckHResult(UInt32 hr)
   at MS.Internal.XcpImports.SetValue(INativeCoreTypeWrapper obj, DependencyProperty property, DependencyObject doh)
   at MS.Internal.XcpImports.SetValue(INativeCoreTypeWrapper doh, DependencyProperty property, Object obj)
   at System.Windows.DependencyObject.SetObjectValueToCore(DependencyProperty dp, Object value)
   at System.Windows.DependencyObject.SetValueInternal(DependencyProperty dp, Object value, Boolean allowReadOnlySet, Boolean isSetByStyle, Boolean isSetByBuiltInStyle, PropertyInvalidationReason reason)
   at System.Windows.DependencyObject.SetValueInternal(DependencyProperty dp, Object value)
   at System.Windows.DependencyObject.SetValue(DependencyProperty dp, Object value)
   at System.Windows.Controls.ContentControl.set_Content(Object value)
   at Telerik.Windows.Controls.GridView.GridViewHeaderCell.SetHeaderText()
   at Telerik.Windows.Controls.GridView.GridViewHeaderCell.OnApplyTemplate()
   at System.Windows.FrameworkElement.OnApplyTemplate(IntPtr nativeTarget)}"

  void webService_SearchPatientsCompleted(object sender, SearchPatientsCompletedEventArgs e)
        {
            var data = new System.Windows.Data.PagedCollectionView(e.Result);
            RadGridViewPatients.ItemsSource = DataPagerPatients.Source = data;  <----HERE!
          
        }



CS
 LocalizationManager.Manager = new LocalizationManager()
            {
                ResourceManager = SLToolsProto.Resources.StringLibrary.ResourceManager
            };


XAML



<telerikGridView:GridViewDataColumn Width="50" DataMemberPath="PatientID" >
                    <telerikGridView:GridViewDataColumn.Header>
                        <TextBlock     TelerikControls:LocalizationManager.ResourceKey="XamWebGridPatients_PatientID" />
                        </telerikGridView:GridViewDataColumn.Header>
                </telerikGridView:GridViewDataColumn>
               

0
Abeer Ibrahim
Top achievements
Rank 1
answered on 08 Sep 2009, 05:43 PM

I have the same problem (and same exception) when trying to localize RadGridView column headers using the proposed solution below.  Can you explain how does it know to map the Text property of the TextBlock to the value of the ResourceKey?? I do not see where/when in the example below this association takes place:

<telerikGridView:GridViewDataColumn.Header>
                        <TextBlock     TelerikControls:LocalizationManager.ResourceKey="XamWebGridPatients_PatientID" />
                        </telerikGridView:GridViewDataColumn.Header>

Thanks!
0
Pavel Pavlov
Telerik team
answered on 11 Sep 2009, 09:07 AM
Hi

There were some issues with assigning UIElements as column header, but it was fixed. The fix should be available in the Latest Internal Build which will be released later today. You will be able to get it from your Client.NET.

When the build is released, can you try to upgrade to its binaries and see whether the issue will be resolved.

In case the issue is not resolved with the Latest Internal Build, we would like to ask you to zip and attach your project and we will immediately take a look at it to see what is going wrong.

About the mapping between Text property and resource key :
Our LocalizationManager has some automatic logic to search for Text  or Content  properties and set them .

For more details on LocalizationManager usage please check here.


Greetings,
Pavel Pavlov
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
0
Abhi Basu
Top achievements
Rank 1
answered on 11 Sep 2009, 05:20 PM
I will take a look at the latest build as soon as it is available. That will solve the smaller problem - of localizing the grid column headers. But, what about the bigger problem of being able to set other properties of controls, not just the ones your localization control automatically sets? Is there any plan for such support?

Also, how do your controls fare with tools like locbaml that expect standard bindings in controls to be able to translate them into unique IDs that can be used to import/export resx files to be managed/sent for translations?

Thanks.
0
Abhi Basu
Top achievements
Rank 1
answered on 14 Sep 2009, 09:32 PM
The latest internal build has fixed the column localization problem, but I get an exception when moving any columns that have been placed into the grouping bar (on top).

Secondly, how do I localize the items on the filtering popup window that is part of the radgridview control?

Thanks.
0
Pavel Pavlov
Telerik team
answered on 16 Sep 2009, 03:09 PM
Hello Abhi Basu,

We have taken care of the problem with the exception being raised. The fix should be present in the upcoming internal build ( I believe in the upcoming beta version as well) . 

A way to localize  the filtering popup is  illustrated here : http://www.telerik.com/help/silverlight/gridview-localization.html.

I have  elevated your suggestions to the people developing the localization logic . Thank you for the productive feedback . I believe improvements in that direction will be made shortly.

One more time , thank you for the suggestions! I have updated your Telerik points.

Regards,
Pavel Pavlov
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
0
Sujatha
Top achievements
Rank 1
answered on 16 Nov 2012, 05:45 PM
Hi Pavel,

I have tried to implement solution given here but it did not work becasue 'GridViewDataColumn' does not contain 'Header' element.

My application Software specifications.
1. .net Framework 4.0 (VS 2010)
2. SilverLight 5
3. RadControlsForSilverlightSetup_2012_3_1017 (exe) used for telerik.

Please help me to implement DataGridView Header content Localization.its very urgent to me.

Thanks
Suzy
Tags
GridView
Asked by
Abhi Basu
Top achievements
Rank 1
Answers by
Abhi Basu
Top achievements
Rank 1
Pavel Pavlov
Telerik team
Abeer Ibrahim
Top achievements
Rank 1
Sujatha
Top achievements
Rank 1
Share this question
or