Enum TypeConverter and description

6 posts, 1 answers
  1. Simon Wolters
    Simon Wolters avatar
    20 posts
    Member since:
    Mar 2010

    Posted 06 May 2010 Link to this post

    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.


  2. Answer
    Stefan Dobrev
    Admin
    Stefan Dobrev avatar
    790 posts

    Posted 12 May 2010 Link to this post

    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.
  3. DevCraft banner
  4. Simon Wolters
    Simon Wolters avatar
    20 posts
    Member since:
    Mar 2010

    Posted 12 May 2010 Link to this post

    Hi Stefan,
    That works great - thank you very much!
  5. Raphael
    Raphael avatar
    2 posts
    Member since:
    Jan 2014

    Posted 12 Oct in reply to Stefan Dobrev Link to this post

    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

  6. Dilyan Traykov
    Admin
    Dilyan Traykov avatar
    371 posts

    Posted 17 Oct Link to this post

    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.
  7. Raphael
    Raphael avatar
    2 posts
    Member since:
    Jan 2014

    Posted 31 Oct in reply to Dilyan Traykov Link to this post

    Hallo,

     

    Works great for me, thank you very much!

     

    Kind Regards,

    Raphael

Back to Top
DevCraft banner