How to localize RadGrid column headers

10 posts, 0 answers
  1. Abhi Basu
    Abhi Basu avatar
    7 posts
    Member since:
    Sep 2009

    Posted 02 Sep 2009 Link to this post

    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.
           
  2. Abhi Basu
    Abhi Basu avatar
    7 posts
    Member since:
    Sep 2009

    Posted 04 Sep 2009 Link to this post

    Can anyone help me with this? How do I map my non-autogenerated columns to resx file items in the XAML file?

    Thanks.
  3. Pavel Pavlov
    Admin
    Pavel Pavlov avatar
    2039 posts

    Posted 07 Sep 2009 Link to this post

    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.
  4. Abhi Basu
    Abhi Basu avatar
    7 posts
    Member since:
    Sep 2009

    Posted 08 Sep 2009 Link to this post

    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>
                   

  5. Abeer Ibrahim
    Abeer Ibrahim avatar
    2 posts
    Member since:
    Sep 2009

    Posted 08 Sep 2009 Link to this post


    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!
  6. Pavel Pavlov
    Admin
    Pavel Pavlov avatar
    2039 posts

    Posted 11 Sep 2009 Link to this post

    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.
  7. Abhi Basu
    Abhi Basu avatar
    7 posts
    Member since:
    Sep 2009

    Posted 11 Sep 2009 Link to this post

    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.
  8. Abhi Basu
    Abhi Basu avatar
    7 posts
    Member since:
    Sep 2009

    Posted 14 Sep 2009 Link to this post

    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.
  9. Pavel Pavlov
    Admin
    Pavel Pavlov avatar
    2039 posts

    Posted 16 Sep 2009 Link to this post

    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.
  10. Sujatha
    Sujatha avatar
    1 posts
    Member since:
    Nov 2012

    Posted 16 Nov 2012 Link to this post

    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
Back to Top