cancel
Showing results for 
Search instead for 
Did you mean: 

Setting Dimension display mode and flattening hierarchies on the fly - Live BW conn

JBARLOW
Contributor
0 Kudos

Requirement
I have a table that we want users to be able to add/remove dimensions & measures as they like;
this is easily accomplished via the native navigation panel menu - we give them a button to open it:

Button code:
Table_1.openNavigationPanel();

Problem:
At runtime the table contains say, 3 dimensions - all formatted to show only the description with a flat hierarchy.
If they user then edits the table and adds a different dimension it will default to ID & Description display mode.
My code below works - it loops through all the dims and sets the display mode as we'd like.

However we need this code to run during the 'onResultChanged' event for the table - this makes it dynamic/run on the fly when users change things.
The issue is that it continually loops forever as it keeps triggering an onResultChanged event....
I'm aware of the 'break;' parameter and the setrefreshPaused(true); -- but not sure where in the code we can place them to stop the looping *note we're using Live BW connections*

Code: to loop through dimensions in the table and set any hierarchies to flat + show the Dimension description

var dimensions = Table_1.getDataSource().getDimensions();
for (var i=0;i<dimensions.length;i++)
{ Table_1.getDataSource().setHierarchy(dimensions[i],'__FLAT__'); Table_1.getDataSource().setMemberDisplayMode(dimensions[i],MemberDisplayMode.Description); }

Accepted Solutions (1)

Accepted Solutions (1)

JBARLOW
Contributor
0 Kudos

Thanks bob.meincke sorted the looping out with a quick check on the display mode as per the code below.

var dimensions = Table_1.getDataSource().getDimensions();
for (var i=0;i<dimensions.length;i++)
{ var mode = Table_1.getDataSource().getMemberDisplayMode(dimensions[i]);
if(mode !==MemberDisplayMode.Description ) {Table_1.getDataSource().setMemberDisplayMode(dimensions[i],MemberDisplayMode.Description); }}

Answers (1)

Answers (1)

Bob0001
Advisor
Advisor
0 Kudos

Hi jbarlowjb,

what happens if you apply all changes on load of the app or after changing the model? The settings should be kept, when removing/adding dimensions.

To avoid the endless loop, you may check the hierarchy and display mode before and only change it if needed.

JBARLOW
Contributor
0 Kudos

Hi Bob,

Yep, i've tried running the code in the onInitialisation event of the app - doesn't work 😞
It only seems to be applied to Dimensions that are currently present in the table - which is annoying.

I'll try checking the modes in the loop and see if that helps

onInitialisation code:

var dimensions = Table_1.getDataSource().getDimensions();
for (var i=0;i<dimensions.length;i++)
{ Table_1.getDataSource().setHierarchy(dimensions[i],'__FLAT__'); Table_1.getDataSource().setMemberDisplayMode(dimensions[i],MemberDisplayMode.Description); }