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

Converter support in group headers

2 Answers 49 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Henrik
Top achievements
Rank 1
Henrik asked on 13 Feb 2012, 10:34 AM
Hi

In quite a few places i am using converters with the RadGridView to convert the values in the domain model to values presented in the users. I have attached an example where a column is bound to an enum which is converted to a string by a IValueConverter (by using a ressource file for easy i18n)

As there seems to be no support for the converter notion directly in the RadGridView i have done this in the following way:

<telerik:GridViewDataColumn x:Name="sourceColumn" IsReadOnly="True"  Header="Source">
    <telerik:GridViewDataColumn.CellTemplate>
        <DataTemplate>
            <TextBlock Text="{Binding RouteSource, Converter={StaticResource RouteSourceConverter}}" />
        </DataTemplate>
    </telerik:GridViewDataColumn.CellTemplate>
</telerik:GridViewDataColumn>

However when i then group on these columns, the value is of course not converted. I have attached a screenshot showing this.
I could probably just define a custom group header template. But the only thing i want is to get the value passed through my converter. 


Is there an easy way to acheive this? If using a custom group header tempalte, how would i do this so it looks like the default group headers - but just with the value from the columns converted? 

2 Answers, 1 is accepted

Sort by
0
Accepted
Dimitrina
Telerik team
answered on 13 Feb 2012, 12:13 PM
Hello,

 When you use a Converter in the DataMemberBinding of a column and group by that column, the result will be grouped by the converted value.
 In your case you should set the DataMemberBinding for the GridViewDataColumn. I have attached a sample project for a reference. 

All the best,
Didie
the Telerik team
Sharpen your .NET Ninja skills! Attend Q1 webinar week and get a chance to win a license! Book your seat now >>
0
Henrik
Top achievements
Rank 1
answered on 13 Feb 2012, 12:26 PM
Thank you very much for the swift response. I have no idea why i got the impression i couldn't use converters on the data member binding property. It works completely as i would expect it to do. 

Thanks!
Tags
GridView
Asked by
Henrik
Top achievements
Rank 1
Answers by
Dimitrina
Telerik team
Henrik
Top achievements
Rank 1
Share this question
or