* It is assumed that the dropdown list has already been populated with a list of dimension objects
Widgets
Dropdown List: dropdown_1 (referenced using the ‘this’ syntax
Table: Table
Script placed in the dropdown onSelect event
var selected_dimension = this.getSelectedKey();
// as the script is placed in the dropdown widget we can use 'this' instead of the widget name (dropdown_1)
// get the second dimension in the table – the row number starts at 0, so row 1 is the 2nd dimension in the table
var row2_dimension = Table.getDimensionsOnRows()[1];
// remove the dimension from the table
Table_1.removeDimension(row2_dimension);
// add the dimension selected in the dropdown to the tableTable_1.addDimensionToRows(selected_dimension,1);
Code language: JavaScript (javascript)
