Format Column Group Header

3 posts, 0 answers
  1. Shaun
    Shaun avatar
    39 posts
    Member since:
    Sep 2012

    Posted 17 Aug 2014 Link to this post


    I have the following

    provider.ColumnGroupDescriptions.Add(new PropertyGroupDescription() { PropertyName = "DispatchDate", GroupComparer = new GroupNameComparer() });
    provider.ColumnGroupDescriptions[0].SortOrder = Telerik.Pivot.Core.SortOrder.Ascending;

    DispatchDate is a Datetime field.

    So far so good.

    But can I format the date field to read MM YY (May 14) in the column header?

    I tried to change the DispatchDate to a string, but that messes up the sort, so if I could format the date field that would be great.


  2. Dimitar
    Dimitar avatar
    2983 posts

    Posted 19 Aug 2014 Link to this post

    Hello Shaun,

    Thank you for writing.

    As the following code snippet demonstrates, you should use the GroupElementFormatting event to change the header cells text:
    void radPivotGrid1_GroupElementFormatting(object sender, Telerik.WinControls.UI.PivotGroupElementEventArgs e)
        DateTime Value ;
        if (DateTime.TryParse(e.GroupElement.Data.Name, out Value))
            e.GroupElement.Text = String.Format("{0:MMM yy}", Value);

    Please let me know if there is something else I can help you with.

    Check out Telerik Analytics, the service which allows developers to discover app usage patterns, analyze user data, log exceptions, solve problems and profile application performance at run time. Watch the videos and start improving your app based on facts, not hunches.
  3. Shaun
    Shaun avatar
    39 posts
    Member since:
    Sep 2012

    Posted 19 Aug 2014 in reply to Dimitar Link to this post

    Hi Dimitar,

    Thanks for your help, works a treat.


Back to Top