🍉 Meet Flexmonster Pivot Table & Charts 2.9.Check out all hot features!
Get Free Trial

Can CSV column data type be changed at runtime?

Serban Vasile asked on August 11, 2019

Quick question…some of our users like the split dates (D+, D4+, etc), some like the dates as original (2019-08-24). Would like to enable that as an option at runtime, maybe through a custom toolbar button, or something like that.
Is that possible?

2 answers

Vera Didenko Vera Didenko Flexmonster August 12, 2019

Thank you for your question.
1) How to change the date data type during runtime:

In Flexmonster, for CSV and JSON data sources, the date data type can be changed via the defaultDateType option.
The defaultDateType parameter specifies which data types should be applied to date fields by default, for example:

options: {
"defaultDateType": "date string"

This report configuration can be changed during runtime via the getReport() and setReport() API calls as shown in the code snippet below:

var report = pivot.getReport({withDefaults: true});
report.options.defaultDateType = "year/month/day";

An important remark is that data from date fields should be in the ISO 8601 date format to work properly.
Please keep in mind that changing the data type requires reloading the data.

2) Adding a new Tab to the Toolbar:
The Toolbar can be customized using the beforetoolbarcreated event to add/remove/change the Toolbar’s Tabs.
Here is a JSFiddle example for illustration: https://jsfiddle.net/flexmonster/5m0js7wr/.
Please let us know if everything works fine for you.
Best Regards,

Serban Vasile August 12, 2019

Perfect, that is what I was looking for, thanks a bunch.

Please login or Register to Submit Answer