Download Free Trial

How to get date information from columns

I have JSON data source and one the columns is of “Date” type  – (Such field will be split into 3 different fields: Year, Month, Day.). Now I have all the 3 fields selected as columns in the pivot. i.e. Date.Year, Date.Month and Day. When I click on cell, I want to create the date object so that I can get additional data from the server for this date. 
Right now getSelectedCell() gives cell object, which has columns array. Here i get all 3 columns. Year column is giving me year value i.e. say 2017, but for month it gives me month name  and that too in that locale.
Can you please suggest how to get the month value in number so that I can create the correct date object ?

3 answers

Ian Sadovy Flexmonster May 9, 2017

Hello Sohan,
Thank you for the question.
Actually, there is no straightforward way to get the month number from API. 
But, month labels are defined in the localization, so you can use its values to get month order number.
For example, please take a look at the following workaround – (see line 24).
Please let me know if it works for you.

Sohan May 10, 2017

Thanks Ian, that will work.
One thing, how to get the localization object, so that I can get the months object from it ? I have defined the pivot as below. 
So I have all the objects inside en.json, I know i can load this file again using jquery, but that will be loading the same file twice, which I think should be avoidable.

global: {
localization: "loc/en.json"
licenseKey: response.licenseKey,
beforetoolbarcreated: customizeToolbar,
componentFolder: "libs/flexmonster/",
toolbar: true,
height: "100%",
width: "100%",
report: flexReport
Tanya Gryshko Flexmonster May 10, 2017

Hello Sohan,
Thank you for the feedback. We recommend the following approach: load en.json using jQuery in the first place. Then you can get the months object from it and set localization as inline JSON instead of URL to localization JSON file. So, localization file would not be loaded twice.
Let us know if you have further questions.

Please login or Register to Submit Answer