Get the selected rows in a table

Contents[Hide]

1. Overview

Learn how to get the selected row ordinals and the selected row hierarchy members in a table using script.

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 a button click script to get the selected row indexes
Add a button click script to get the selected row indexes

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.

Click the button to show the selected row ordinals in the label
Click the button to show the selected row ordinals 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.

Click the button to show the selected hierarchy members in the label
Click the button to show the selected hierarchy members in the label

4. See also

Dundas Data Visualization, Inc.
500-250 Ferrand Drive
Toronto, ON, Canada
M3C 3G8

North America: 1.800.463.1492
International: 1.416.467.5100

Dundas Support Hours: 7am-6pm, ET, Mon-Fri