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

Grouping shows wrong name in header

1 Answer 49 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Licenses
Top achievements
Rank 1
Licenses asked on 09 Aug 2010, 01:06 PM
Hello,

I have a list of Employees that is set as the ItemsSource for a RadGridView. The headers of each column are determined by the metadata defined on the EmployeeEntity. This way the column headers are always shown in the right language for the user. This works as expected:

Employee:
[MetadataTypeAttribute(typeof(Employee.EmployeeMetadata))]
    public partial class Employee
    {
       internal sealed class EmployeeMetadata
        {
            // Metadata classes are not meant to be instantiated.
            private EmployeeMetadata()
            {
            }
 
            [Display(ResourceType = typeof(EmployeeResources), Name = "NameDisplay")]
            public string Name{ get; set; }
 
            [Display(ResourceType = typeof(EmployeeResources), Name = "CategoryDisplay")]
            public string EmployeeCategory{ get; set; }
   }
}

XAML:
<telerik:RadGridView x:Name="empList" ItemsSource="{Binding Employees}" >
   <telerik:RadGridView.Columns>
      <telerik:GridViewDataColumn DataMemberBinding="{Binding Name}" />
      <telerik:GridViewDataColumn DataMemberBinding="{Binding EmployeeCategory}"/>
   </telerik:RadGridView.Columns>
   <telerik:RadGridView.GroupDescriptors>
      <telerik:GroupDescriptor Member="EmployeeCategory" />
   </telerik:RadGridView.GroupDescriptors>
</telerik:RadGridView>

This shows fore example as the headers for the datacolumns: "Naam" and "MedewerkersCategorie", because that is the way "NameDisplay" and "CategoryDisplay" are defined in the resources file.

The problem is when I define groupîng like I did in the example, the group header simply shows "EmployeeCategory" and not "MedewerkersCategorie". If I however not group programmatically but via the user interface, the correct header name is shown.

I've searched the forums and the only workable solution they propose is to catch the grouping event of the grid, and whenever the name of the column to group upon is equal to "EmployeeCategory" return a string from the resources file.

What is the correct way to solve this situation?

Thank you,
Sodi We

1 Answer, 1 is accepted

Sort by
0
Maya
Telerik team
answered on 11 Aug 2010, 08:00 AM
Hello Sodi We,

The workaround with handling the Grouping event is quite correct. You may take a look at this forum thread for a reference. 

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
Licenses
Top achievements
Rank 1
Answers by
Maya
Telerik team
Share this question
or