We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. (Last updated on: June 24, 2019).
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

Date Formatting Problem

Thread ID:

Created:

Updated:

Platform:

Replies:

145417 Jun 20,2019 01:10 PM UTC Jun 25,2019 06:12 AM UTC Angular - EJ 2 6
loading
Tags: PivotGrid
Isaias Chalvatzoglou
Asked On June 20, 2019 01:10 PM UTC

Good Afternoon.

In your documentation https://ej2.syncfusion.com/angular/documentation/pivotview/how-to/customize-number-date-and-time-values/ you say that we can customize date and time formatting. On preview tab i see that all dates have the same value (01/01/1970-02:00).



 formatSettings: [{ name: 'Sold', format: 'dd/MM/yyyy-hh:mm', type: 'date' }],


I need to make a pivot grid like this and i found out that the problem really exists.



The real date values are 18-06-2019 09:22, 18-06-2019 10:15 e.t.c.

Jagadeesan Pichaimuthu [Syncfusion]
Replied On June 21, 2019 09:24 AM UTC

Hi Isaias, 
  
Currently, we don’t have option to format date in value axis directly using formatSettings. But, you can display the date in values by using aggregationCellInfo event. Please refer the following code snippet. 
 
Code Snippet: 
aggregateCellInfo(args) { 
    if (args.columnCellType == 'grandTotal') { 
      args.value = ''; 
      for (var i = 0i < args.cellSets.lengthi++) { 
        if (typeof (args.cellSets[i][args.fieldName]) == "number") { 
          args.value = args.value + args.cellSets[i][args.fieldName]; 
        } 
      } 
    } else if (args.cellSets[0]) { 
      args.value = args.cellSets[0][args.fieldName]; 
    } 
  } 
  
  
  
Note: We formatted the Sold Amount (Number) into the date in the document. Number regarded as count in this case. If the count is the same for all numbers, all values will display the same date. 
  
Please let us know if you need further assistance on this. 
  
Regards, 
Jagadeesan

Isaias Chalvatzoglou
Replied On June 21, 2019 10:31 AM UTC

Hi Jagadeesan,

Problem solved.

Thank you for your quick response!



Isaias Chalvatzoglou
Replied On June 21, 2019 10:50 AM UTC

Hello again.

When I'm exporting same pivot grid to excel, date saved in the excel as '2019-06-20T06:22:00'. There is a way datetime to be saved like the formatting i defined in format settings 'dd/MM/yyyy hh:mm' ?



Jagadeesan Pichaimuthu [Syncfusion]
Replied On June 24, 2019 08:41 AM UTC

Hi Isaias, 
  
You can achieve your requirement using beforeExcelExport event. Please refer following code snippet. 
  
Code Snippet: 
dataBound(args): void { 
    this.pivotGridObj.grid.beforeExcelExport = function (args) { 
      var data = (args as any).gridObject.dataSource; 
      for (var i = 0i < data.lengthi++) { 
        for (var j = 0j < Object.keys(data[i]).lengthj++) { 
        if (data[i][j].axis == 'value') { 
          data[i][j].value = data[i][j].formattedText; 
        } 
      } 
    } 
  } 
} 
  
  
Please let us know if you need further assistance on this. 
  
Regards, 
Jagadeesan

Isaias Chalvatzoglou
Replied On June 24, 2019 10:08 AM UTC

Hi Jagadeesan,

It works!

Thank you

Dinesh Babu Yadav [Syncfusion]
Replied On June 25, 2019 06:12 AM UTC

Hi Isaias, 
 
Thanks for the update. Please get back to us if you need further other assistance from us. 
 
Regards, 
Dinesh Babu Yadav 


CONFIRMATION

This post will be permanently deleted. Are you sure you want to continue?

Sorry, An error occured while processing your request. Please try again later.

Please sign in to access our forum

This page will automatically be redirected to the sign-in page in 10 seconds.

Warning Icon You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.Close Icon

Live Chat Icon For mobile
Live Chat Icon