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

Format Column Group Header

2 Answers 93 Views
PivotGrid and PivotFieldList
This is a migrated thread and some comments may be shown as answers.
Shaun
Top achievements
Rank 1
Shaun asked on 17 Aug 2014, 11:34 PM
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 Answers, 1 is accepted

Sort by
0
Dimitar
Telerik team
answered on 19 Aug 2014, 02:03 PM
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.
 
0
Shaun
Top achievements
Rank 1
answered on 19 Aug 2014, 09:38 PM
Hi Dimitar,

Thanks for your help, works a treat.

Cheers

Shaun
Tags
PivotGrid and PivotFieldList
Asked by
Shaun
Top achievements
Rank 1
Answers by
Dimitar
Telerik team
Shaun
Top achievements
Rank 1
Share this question
or