Skip to Content
Technical Articles
Author's profile photo Peter Gessler

Context Menu: Activate and deactivate hierarchy display in table component

Problem

We are using an analysis table in Design Studio on which users can apply filters. Many dimensions are using hierarchies, therefore, filters can be applied on hierarchy nodes. In some scenarios, the users asked to switch from the hierarchy display to a flat presentation.

With the standard context menu, the only entry which could be used to achieve this is “Select Hierarchy”. When you select “No Hierarchy” from theĀ  hierarchy list, the analysis table will show the flat representation. But at the same time, all hierarchy node filters are discarded.

Solution approach

We enhanced the standard context menu with a custom setting to only deactivate the display hierarchy. The flat presentation is available and all hierarchy filters are maintained.

Steps

  1. Select the CONTEXT_MENU component
  2. In Properties, go to Custom menu options
  3. Create a new entry, name it “(De-)Activate Hierarchy”
  4. Click on “Edit Script” to open the editor
  5. Paste the code snippet
  6. Confirm all windows with “OK”

Code Snippet Design Studio 1.6

if(me.getClickArea() == 'MEMBER' || me.getClickArea() == 'DIMENSION'){
  //only execute the actions if Member or Dimension has been clicked
var context = me.getContext();
  context.forEach(function(value, key) {
   if(me.getDataSource().isHierarchyAssigned(key)){
     //only continue if the dimension has a hierarchy assigned
    if(me.getDataSource().isHierarchyActive(key)){
         me.getDataSource().deactivateHierarchy(key);
    } else {
         me.getDataSource().activateHierarchy(key);
    }
   }
  });
}else{
  // if needed, add action or message if neither Member nor Dimension has been clicked
}

The above snippet will turn the display hierarchy on or off depending on the current state and only if a hierarchy is assigned.

Code Snippet Lumira Designer 2.2 and above

if(CONTEXT_MENU.getSelectionType() == ClickArea.MEMBER || CONTEXT_MENU.getSelectionType() == ClickArea.DIMENSION){
  //only execute the actions if Member or Dimension has been clicked
  
var context = CONTEXT_MENU.getSelection();
  context.forEach(function(value, key) {
   if(CONTEXT_MENU.getDataSource().isHierarchyAssigned(key)){
     //only continue if the dimension has a hierarchy assigned

    if(CONTEXT_MENU.getDataSource().isHierarchyActive(key)){
         CONTEXT_MENU.getDataSource().deactivateHierarchy(key);
    } else {
         CONTEXT_MENU.getDataSource().activateHierarchy(key);
    }
   }
  });
 
}else{
  // if needed, add action or message if neither Member nor Dimension has been clicked
}

The codeword “me” is not available anymore for the context menu script. Therefore you have to exchange it with the name of the context menu component like CONTEXT_MENU. Additionally, some expressions were deprecated and have been replaced above compared to 1.6.

Known issues

Display: As of now (we are working with BO Design Studio 1.6) it is not possible to turn this entry on or off dynamically per component. So once you implement this, the entry will show up for every context menu. Read more on context menu tweaking here: Design Studio 1.5: View on Context Menu Parameterization

BEx query structure: When executing this on a hierarchical BEx query structure, an error message will be generated because it is a Member and a hierarchy is assigned, but deactivation of the hierarchy is not possible.

Assigned Tags

      Be the first to leave a comment
      You must be Logged on to comment or reply to a post.