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

Enum TypeConverter and description

5 Answers 290 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Simon Wolters
Top achievements
Rank 1
Simon Wolters asked on 06 May 2010, 02:00 PM
Hi,

I am using an EnumTypeConverter and description annotations to localize enums in my application (the description values are resource keys) like this:

[TypeConverter(typeof(EnumToStringUsingDescription))] 
    public enum AssetType 
    { 
        [Description("Strings.AssetTypeOvernightLoanCaption")] 
        OvernightLoan = 0, 
        [Description("Strings.AssetTypeTimeDepositCaption")] 
        TimeDeposit 
    } 

Now my problem is that the telerik RadGridView seems to ignore the TypeConverter and just calls Enum.ToString(). 
Is there any way to force the usage of my TypeConverter? There are many enums in serveral languages in my application, so IValueConverters are not an option.

Thank you very much in advance.


5 Answers, 1 is accepted

Sort by
0
Accepted
Stefan Dobrev
Telerik team
answered on 12 May 2010, 08:30 AM
Hi Simon,

Can you try with custom CellTemplate for this enum columns? Something like this:
<telerik:GridViewDataColumn DataMemberBinding="{Binding MyEnum}">
    <telerik:GridViewDataColumn.CellTemplate>
        <DataTemplate>
            <TextBlock Text="{Binding MyEnum}" />
        </DataTemplate>
    </telerik:GridViewDataColumn.CellTemplate>
</telerik:GridViewDataColumn>

Kind regards,
Stefan Dobrev
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
Simon Wolters
Top achievements
Rank 1
answered on 12 May 2010, 08:39 AM
Hi Stefan,
That works great - thank you very much!
0
Raphael
Top achievements
Rank 1
answered on 12 Oct 2016, 04:17 PM

Hallo Stefan,

Although this solution works fine, I'd like to have like to see something less workaround-ish in my code. Is there some alternative solution for the problem?

Kind Regards,
Raphael

0
Dilyan Traykov
Telerik team
answered on 17 Oct 2016, 09:23 AM
Hello Raphael,

Another way to achieve the desired behavior would be to use the approach suggested in this blog post. I'm attaching a sample project with the implementation.

Please let me know whether such an approach would work for you.

Regards,
Dilyan Traykov
Telerik by Progress
Do you need help with upgrading your AJAX, WPF or WinForms project? Check the Telerik API Analyzer and share your thoughts.
0
Raphael
Top achievements
Rank 1
answered on 31 Oct 2016, 12:07 PM

Hallo,

 

Works great for me, thank you very much!

 

Kind Regards,

Raphael

Tags
GridView
Asked by
Simon Wolters
Top achievements
Rank 1
Answers by
Stefan Dobrev
Telerik team
Simon Wolters
Top achievements
Rank 1
Raphael
Top achievements
Rank 1
Dilyan Traykov
Telerik team
Share this question
or