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

getreport to return layout/config return without data or save method return to function

Brendan Fry asked on January 23, 2020

I have been looking at the following links
https://www.flexmonster.com/api/save/  — Gives the data set I want but there is no option to return to a function, just sends to server or local file.
https://www.flexmonster.com/api/getreport/— returns the data by default, this is a problem with 1 million rows
I would like the save to return to a function so I can handle the JSON object myself or the getreport function have the option to return the same datasource set as the save function without the data but with the first data row with the field config.
Do you have any suggestions?

3 answers

Illia Yatsyshyn Illia Yatsyshyn Flexmonster January 23, 2020

Hello, Brendan,
Thank you for reaching out to us.
We would like to kindly inform you that both save and getReport API calls return the inline JSON data contained as a value of the data property. In case the data set is placed in the file, and the reference is specified as a value of the filename property, only the link to the file will be saved.
In case you are using the inline JSON as a data source, saving the whole data set can be avoided using an approach described within one of the threads mentioned by you.
In case the meta-object (first object of an array) has to be saved, we recommend preprocessing the data so the whole array except its first element is deleted. E.g.:

var report = flexmonster.getReport();
report.dataSource.data = [report.dataSource.data[0]];

However, such a workaround can be avoided by using the mapping object, allowing to define field data types, captions, and multi-level hierarchies, grouping fields under separate dimensions, and setting other view configurations of hierarchies from the CSV, JSON, and OLAP data sources. The object itself is a property of the dataSource object and will be included in the report, both using the save and getReport methods.
More information about the mapping object and its properties can be found by the link: Mapping Object.
We hope it works for you.
Please let us know in case you have additional questions.

Brendan Fry January 24, 2020

Hi Illia Yatsyshyn, thanks for that. I was going to do that but thought there may be a better way as I don’t want all the data. I will see how this performs with a large dataset as it is possible we will have 850k to 1mn rows. It would be easier if the getreport method could have the option of not returning the data.
If performance is not acceptable I will use the mapping object as suggested.
How would you configure the mapping object from the current user configured report?
Do you have any examples of storing/retrieving a mapping?

Illia Yatsyshyn Illia Yatsyshyn Flexmonster January 24, 2020

Hello, Brendan,
Thank you for your feedback.
We would like to kindly draw your attention to the fact that such a large data set will unlikely be presented as an inline JSON. However, in case it is, we highly recommend separating the data and the report in the way the data is stored within the remote file. In case of using such an approach, no data will be included in the object returned by the getReport function.
As for storing and retrieving the mapping, we recommend checking out an example we prepared in order to illustrate such a functionality.
We hope it fits you.
Best regards,

This question is now closed