Despite the COVID-19 outbreak, our team continues operating at full speed. We are always here to support and answer all your questions.

Feel free to reach out by filling this quick form.

Fill the form
Get Free Trial

How to save slice and addCalculatedMeasure for user and loaded for custom data source

Answered
Brad Huang asked on March 25, 2021

Because I will save slice and addCalculatedMeasure for user,
[Case 1] I want to load addCalculatedMeasure into fieldsList.
[Case 2] If user has slice, I want to addCalculatedMeasure into slice and run query.

But I failed in both cases.
Case 1: I want to load addCalculatedMeasure into fieldsList.
Step1. init pivot without opening fieldsList
Step2. addCalculatedMeasure
Step3. openFeilds with CalculatedMeasure inside

var pivot = new Flexmonster(report: {dataSource: {type: "api",url: 'myURL'},
slice:null,//no slice
options:{configuratorActive: false}});//Do not open field list
pivot.addCalculatedMeasure({formula: 'OOO', uniqueName: "XXX"});//addCalculatedMeasure
pivot.openFieldsList();//open fields

Case 2: If user has slice, I want to addCalculatedMeasure into slice and run query.
Step1. init pivot without opening fieldsList
Step2. addCalculatedMeasure
Step3. openFeilds with CalculatedMeasure inside

var pivot = new Flexmonster(report: {dataSource: {type: "api",url: 'myURL'},
slice:null,//no slice
options:{configuratorActive: false}});//Do not open field list
pivot.addCalculatedMeasure({formula: 'OOO', uniqueName: "XXX"});//addCalculatedMeasure
pivot.runQuery(mySlice);//load slice and runQuery

2 answers

Public
Milena Pechura Milena Pechura Flexmonster March 29, 2021

Hello, Brad,
 
Thank you for explaining the issues in detail and for providing the examples. This info greatly helped us to understand the cases better.
Please find our comments regarding each point below.
 
1) First of all, we would like to provide further info about the logic of the configuratorActive property:
If the slice is specified, it is possible to configure whether to show the Field List or not. However, in case the slice is not defined in the report, the Field List will be shown by default.
 
Getting to the point, to disable the default opening of the Field List in your case, we suggest specifying an empty report object in the Flexmonster instance. Then, please use the setReport API call with the calculated measure defined in the slice. With this config, the slice is not loaded to the grid, but the calculated measure is shown in the Field List.
Please see the following example for reference: https://jsfiddle.net/flexmonster/yknodjq8/.
 
2) To add the measure in the slice, we suggest modifying the slice object and using the runQuery API call to set the new slice: https://jsfiddle.net/flexmonster/d7Lszxy5/.
 
Please let us know if our response helped.
Do not hesitate to contact us in case any other questions arise.
 
Best regards,
Milena

Public
Milena Pechura Milena Pechura Flexmonster April 9, 2021

Hi, Brad,
 
Hope you are doing well!
 
We were wondering whether our response helped you with your questions.
Could you please let us know if you achieved the desired component behavior?
 
Looking forward to hearing from you.
 
Kind regards,
Milena

Please login or Register to Submit Answer