Need a special offer?Find out if your project fits.
+

How to get date information from columns

Resolved
Sohan asked on May 9, 2017

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

Public
Ian Sadovy 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 - http://jsfiddle.net/flexmonster/o7dxbshq/ (see line 24).
Please let me know if it works for you.
 
Regards,
Ian

Public
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.
 

$(pivotGridSelector).flexmonster({
global: {
localization: "loc/en.json"
},
licenseKey: response.licenseKey,
beforetoolbarcreated: customizeToolbar,
componentFolder: "libs/flexmonster/",
toolbar: true,
height: "100%",
width: "100%",
report: flexReport
});
Public
Tanya Gryshko 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.
Regards,
Tanya

Please login or Register to Submit Answer