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

How to get and set field values in manually (following layouts, Report filter, columns, rows, values)

MKS asked on June 10, 2019

My requirement is :
Step 1: To GET/SET values, which are present in the Field layouts section like, 1)Report filters, 2)columns, 3)rows and 4)values in FIELDS.
Step 2: then I need to store they in my local database, 
Step 3: Later-on, we need to set back to the different layout on FIELDS. 
My question:
Is there any method available to get/set values from Different layout of FIELDS in flexmonster?
if so can you please advise.
also if isn’t there then please advise any work around is available?


3 answers

Vera Didenko Vera Didenko Flexmonster June 11, 2019

Thank you for your question.
1. In Flexmonster you can get the columns, rows, values and report filters via API calls: getColumns()getRows()getMeasures()getReportFilters().
For example, 

var rows = flexmonster.getRows(); 
var columns = flexmonster.getColumns();
var values = flexmonster.getMeasures();
var report_filters = flexmonster.getReportFilters();

2. You can add Fields to columns, rows, values, or report filters by using the getReport() and setReport() API calls.
For example,

// Get the current report:
var report = flexmonster.getReport();

// Add "Category" to Rows:
report.slice.rows.push({"uniqueName": "Category"});

// Set the modified report:

Please let us know if this works.
You are welcome to contact us in case any questions arise.
Best Regards,

MKS June 13, 2019

Thank you Vera for the answer.
I have one more question, how do i set back to getColumns()getRows()getMeasures()getReportFilters()

i couldn’t see any API like, setColumns(), setRows(), setMeasures(), setReportFilters()

if i need use any key param in said setReport(). please share the key attributes for the colums,rows,measues and reportfilters.

Thank you,

Vera Didenko Vera Didenko Flexmonster June 13, 2019

Thank you for your reply.
The columns, rows, measures, and report filters can be set by using the getReport() and setReport() API calls.
For example, let’s set the columns of the report to
[ {"uniqueName": "Category"}, {"uniqueName": "Color"} ], in other words, we want to display Category and Color in the columns section.
1) For this, first we need to get the current report:

var report = pivot.getReport();

We can check which properties the current report object contains the following way: 


An important remark is that information concerning which fields are present in the rows, columns, measures, and report filters can be accessed through the slice property of the report object.
Also, please check out the full list of parameters that can be set in the report object.
2) Next, let’s access the columns property and set it to
[ {"uniqueName": "Category"}, {"uniqueName": "Color"} ]:

report.slice.columns = [{"uniqueName": "Category"}, {"uniqueName": "Color"}];

Please note that in this case, any other fields which were present in the columns will be replaced with the ones we have set.
If you would like to add Fields without replacing others then it can be done like this:

var columns = pivot.getColumns();

//Add "Category" to columns:
columns.push({"uniqueName": "Category"});

//Add "Color" to columns:
columns.push({"uniqueName": "Color"});

//Set thecolumns:
report.slice.columns = columns;

3) After all needed changes to the report are done, with the setReport() API call the modified report can be set:


We have prepared a JSFiddle example for illustration. 
Please let us know if this works fine for you and if you have any further questions.
Best Regards,

Please login or Register to Submit Answer