Format Column Group Header

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

    Posted 17 Aug 2014 Link to this post

    Hi,

    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.

    Thanks
    Shaun.





  2. Dimitar
    Admin
    Dimitar avatar
    1404 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.

    Regards,
    Dimitar
    Telerik
     
    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. UI for WinForms is Visual Studio 2017 Ready
  4. Shaun
    Shaun avatar
    37 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.

    Cheers

    Shaun
Back to Top