Formatting date om PivotGrid

I would like to be able to change format for a date in pivot table, Can I do it by binding? How can i do it dynamically?


5 Replies

VS Vijayarasan Sivanandham Syncfusion Team May 11, 2022 02:30 PM UTC

Hi Patrycja,

We are a little unclear about your reported issue. Please provide more information related to your query?

  • Details about your scenario with illustrations       
  • Code snippet related to customization of PivotGrid

Kindly revert to us with the above requested details. It will be more helpful for us to check the possibilities to resolve the reported problem.

Regards,
Vijayarasan S



PM Patrycja Maria Karys May 12, 2022 06:27 AM UTC

 

  My scenario: I chose daily interval, meaning that I would like to be able to see date in  format "dd.MM.yyyy HH.mm.ss", but when I change Interval to Monthly I would like to be able to see the table in format "mm.yyyy" .

How can set it dynaically?  



VS Vijayarasan Sivanandham Syncfusion Team May 13, 2022 02:49 PM UTC

Hi Patrycja,

We regret to inform you that format property does not contain support to bind the format value in PivotGrid.

However, your requirement to change the format at run time can be achieved by define the format like below mentioned code snippet,

private void ChangeMonthlyFormat(object sender, RoutedEventArgs e)

{

            //change the date format at run time in PivotGrid

            var getIndexOfDataColumn = this.pivotGrid1.InternalGrid.GetColumnIndexFromName("Date");          

            this.pivotGrid1.PivotRows[getIndexOfDataColumn].Format = "mm.yyyy";           

            this.pivotGrid1.Refresh();

}

 

private void ChangeDailyFormat(object sender, RoutedEventArgs e)

{

           //change the date format at run time in PivotGrid

            var getIndexOfDataColumn = this.pivotGrid1.InternalGrid.GetColumnIndexFromName("Date");

            this.pivotGrid1.PivotRows[getIndexOfDataColumn].Format = "dd.MM.yyyy HH.mm.ss";

            this.pivotGrid1.Refresh();

}


Please find the sample in the attachment and let us know if you have any concerns in this.


Regards,

Vijayarasan S


Attachment: PivotGridControlDemo_406d8be7.zip


PM Patrycja Maria Karys May 18, 2022 01:35 PM UTC

Thanks for response! 



VS Vijayarasan Sivanandham Syncfusion Team May 19, 2022 05:24 AM UTC

Hi Patrycja,


We are glad to know that the reported problem has been resolved at your end. Please let us know if you have any further queries on this. We are happy to help you😊.


Regards,

Vijayarasan S


Loader.
Up arrow icon