cancel
Showing results for 
Search instead for 
Did you mean: 
intapiuser
Community Team Member
Community Team Member
The goal is to allow users to dynamically choose a dimension. The below script will work with a table or a pivot table, but it can be modified to work with other widget types as well. 

Step 1

Create a BloX widget with the below script. It will consist of a simple drop down input and an action button.
{
"style": "",
"script": "",
"title": "",
"showCarousel": true,
"carouselAnimation": {
     "delay": 0,
     "showButtons": false
},
"body": [
{
"type": "Container",
"items": [
     {
     "type": "TextBlock",
     "id": "",
     "class": "",
     "text": "Choices",
     "style": {
          "margin-left": "100px",
          "margin-right": "100px"
          }
     },
     {
     "type": "Input.ChoiceSet",
     "id": "dropdownVal",
     "class": "",
     "displayType": "compact",
     "value": "1",
     "choices": "{choices:colName}",
     "style": {
          "margin-left": "100px",
          "margin-right": "100px"
          }
     }
   ]
 }
],
"actions": [
          {
          "type": "Modify Pivot",
          "title": "Change Dimension" 
          }
     ]
}
Please note: In the above example, the drop down choices are coming from the field 'ColName.' The values in ColName exactly match the target field names in the ElastiCube. The drop down choices could be input manually, but they must exactly match the target field names in the ElastiCube. 

Step 2

Create a table, or pivot table. In this example, I have added two columns. The title in the example is 'Test Widget Title.'

Step 3

Using the console, determine the widget index and target panel.
First, open the developer console and type:
prism.activeDashboard.widgets.$$widgets
You will see a list of all widgets on a dashboard. Look for the correct title or widget type. Note the widget index (it is 6, in this example). 
Second, navigate to:
prism.activeDashboard.widgets.$$widgets[6].metadata.panels
There, note the index of the panel we would like to modify. In this example, we want to modify a column, that is the first object in panels (index = 0).
Finally, open 'Items.' Each item is a field that was added to the columns panel in the target widget. Note the index of the field we want to change. In the example, we want to change the second column (index = 1).

Step 4

Create a custom BloX action to target the correct panel item and change it to the user input value. Use the below script for the action: 
//Variable that stores the user's input
var dropdownInput = payload.data.dropdownVal;
//Variable that stores the target widget
var widget = prism.activeDashboard.widgets.$$widgets[6];

widget.metadata.panels[0].items[1].field.id = "[Exports." + dropdownInput + "]";
widget.metadata.panels[0].items[1].jaql.dim = "[Exports." + dropdownInput + "]";
widget.metadata.panels[0].items[1].jaql.title = dropdownInput;
widget.metadata.panels[0].items[1].jaql.column = dropdownInput;

//Refresh widget
widget.refresh();
The following lines will need to match the incidences from step three.
var widget = prism.activeDashboard.widgets.$$widgets[6];

widget.metadata.panels[0].items[1].x
You can see the above custom action changes four things about the panel item. Please note: the below lines must match the table name where the field resides. Replace it with the appropriate table name:
"[Exports."
That's it! Apply all changes and the drop down filter should change the field in the second column of the table! 
 
If you wish to change a dimension in a different chart, be sure to look for the correct panel in step 3. 
Version history
Last update:
‎03-02-2023 08:34 AM
Updated by:
Contributors
Community Toolbox

Recommended quick links to assist you in optimizing your community experience:

Developers Group:

Product Feedback Forum:

Need additional support?:

Submit a Support Request

The Legal Stuff

Have a question about the Sisense Community?

Email [email protected]

Share this page: