Get the selected rows in a table
1. Overview
Learn how to get the selected row ordinals and the selected row hierarchy members in a table using script.
Script Library sample: Get selected table data
2. Get the selected row ordinals
Create a new dashboard and add a table visualization to it with data.
For this example, we will enable the Allow Multiple Row Selection property of the table.
Also add a button component and a label component.
Add the following script on the Click event of the button.
var indexes = table1.control.getSelectedRowOrdinals(); label1.labelText = indexes.toString();
This script refers to the following API methods and properties:
Switch to View mode and select one or more rows in the table. Click the button to see the selected row indexes/ordinals appear in the label.
3. Get the selected hierarchy members
To get the list of hierarchy members of the selected rows in a row header, change the button click script to use the getSelectedRowHierarchyMembers method:
var members = table1.getSelectedRowHierarchyMembers(); var text = "Selected"; for(i = 0; i < members.length; i++) { text += " | " + members[i].caption; } label1.labelText = text;
Switch to View mode and select one or more rows in the table. Click the button to see the selected hierarchy members appear in the label.