Date formatting into drill through

Sergii Valko asked on July 5, 2019

Hello! I have a simple requirement to have one date format anywhere, but I also need to use collapse feature and filter in the context of date. So I’ve selected data type for date – ‘year/month/day’ and it work perfect with exception detailed view. There the date is in some pattern like ‘yyyy/mmmm/dd’, but i need to ‘MM/dd/yyyy’. Please have a look(https://jsfiddle.net/2qes51ph/1/).

1 answer

Public
Vera Didenko Flexmonster July 8, 2019

Hello, Sergii,
 
 
Thank you for your question.
 
 
Our team suggests using customizeCell to achieve the desired output of date values in the drill-through pop-up window, for example:
 
 
1) Specify the customizeCell property:

customizeCell: customizeDrillThrough

 
2) Provide implementation:

function customizeDrillThrough(cell, data){

   if (data.isDrillThrough && data.type != "header" && data.hierarchy && data.hierarchy.uniqueName == "date") {
    var partsOfDate = data.label.split("/");
    var day = partsOfDate.pop();
    var month = partsOfDate.pop();
    partsOfDate.unshift(day.trim());
    partsOfDate.unshift(month.trim());
    cell.text = partsOfDate.join("/");  
  }

}

 
Here is a JSFiddle example for illustration.
 
 
Also, we would like to point out that the datePattern parameter is used for defining the format for only date string date fields (type: "date string" in JSON, ds+ prefix in CSV).
This is why the date values don’t get affected by the datePattern parameter.
 
For more information about the datePattern parameter please see https://www.flexmonster.com/api/options-object/.
 
 
You are welcome to contact us in case any questions arise.
 
Best Regards,
Vera

Please login or Register to Submit Answer