Last Updated: 31 May 2021 14:32 by ADMIN
Brent Hetland
Created on: 01 Sep 2015 12:20
Category: PivotGrid
Type: Feature Request
PivotGrid - Formatting DateTime in Column Total Headers
One of my PivotGridColumnField's is a smalldatetime field from SQL Server.

In the PivotGrid column header labels I want the dates to be formatted as MMM-yy,  like Aug-15.

I can accomplish that for the detail columns (the non-aggregate columns) by setting the DataFormatString="{0:MMM-yy}"

But that format string is NOT applied to the label of the column total header.  The aggregate column header label still reads:  "08/01/2015 00:00:00 Total"

If you allow a custom format to the detail column headers, it would be logical to assume I want that same custom format used in the aggregate column header.  So in my example, that label should display:   Aug-15 Total

I was told in the Forum that I'd have to parse that column header string in the  CellDataBound Event to get the date portion and then format it and use that to set the header text.  That is a very UGLY solution.

I don't want to strip the word "Total" out of that string and then then convert the date that remains to a string in the date format I want. 

1 comment
Posted on: 15 Jan 2016 12:22

This is not easier solution. But, you can achieve to your goal with code in attached file. 

* You can replace your format/text with "YOUR TEXT" in the code.
* You can add more header check in the code. It's a small example.

P.S.: I got this example from another feedback. But, dont remember the link or page. 

P.S.2: You can make a method as easier to use on everyPage.