Using Selection API Functions for Tables and Charts
You can use the selection API functions for tables and charts to retrieve the currently selected members and their dimensions. For example, you can use this information to retrieve the corresponding data cells from the data source.
The getSelections() functions return an array of Selection objects, each representing a single selection.
Selection API Function | Return Value |
---|---|
Table_1.getSelections() | array of Selection (= Object<string>) |
Chart_1.getSelections() | array of Selection (= Object<string>) |
The properties of such a Selection object are the dimension IDs. The values are the member IDs.
{ "dim1": "member1", "dim2": "member2" }
You can access the selected member of a dimension using var memberId = selection[“dimensionId”];
var selection = Table_1.getSelections()[0]; for (var dimensionId in selection) { var memberId = selection[dimensionId]; }
With a Selection you can retrieve specific data from data sources.
var selection = Table_1.getSelections()[0]; var dataCell = Table_1.getDataSource().getData(selection);
When you specify the selection object passed into a getData() call, a value help for dimensions and members helps you to enter the required dimension and member IDs.