Custom ItemLabelFormat

2 posts, 0 answers
  1. rachel
    rachel avatar
    36 posts
    Member since:
    Sep 2010

    Posted 06 Dec 2011 Link to this post

    i'm using with the pie.
    my ItemLabelFormat #%{P2} #XCAT becouse i want to display the category name.
    my category name is enum, and i want to display the description by the enum.
    Hou could i do that?
  2. Petar Marchev
    Petar Marchev avatar
    996 posts

    Posted 08 Dec 2011 Link to this post

    Hi Rachel,

    There is no way to achieve this out of the box.
    One way to accomplish your goal is to create an additional property in your business class which returns this metadata.

    public class Product
     public ProductName Name { get; set; }
     public double Value { get; set; }
     private string nameDescription;
     public string NameDescription
        if(this.nameDescription == null) this.nameDescription = GetEnumDescription(this.Name);
        return this.nameDescription;
    public static string GetEnumDescription(Enum value)
      FieldInfo fi = value.GetType().GetField(value.ToString());
      DescriptionAttribute[] attributes =
      if (attributes != null &&
        attributes.Length > 0)
        return attributes[0].Description;
        return value.ToString();
    public enum ProductName
      [Description("Xbox descr")]
      [Description("TvSet descr")]
      [Description("Telephone descr")]
      [Description("Desktop descr")]

    Now, you need to set the FieldName in the ItemMapping to be this new property.
    <telerik:ItemMapping DataPointMember="XCategory" FieldName="NameDescription" />

    Hope this helps.

    Best wishes,
    Petar Marchev
    the Telerik team

    Explore the entire Telerik portfolio by downloading the Ultimate Collection trial package. Get it now >>

Back to Top