QSelectionState

Note: STABLE.
This API is reliable and breaking changes are unlikely.

Class

QSelectionState()

Selection state object returned for the selection state created with the selectionState method.

The selectionState interface is the external interface to Qlik Sense selection state data. It allows developers to work with the selection state data returned from Qlik Associative Engine without having a deeper knowledge of internal constructs.

Notification is sent when data is available and notification is triggered after each update.

Note: To receive a notification, bind a listener on OnData for the QSelectionState instance.

Version history

Introduced 2.2

Properties

stateName

Type: String

State name. $ for default state.

selections

Type: Array.QFieldSelections

Selections.

backCount

Type: Number

Number of back steps available.

forwardCount

Type: Number

Number of forward steps available. OnData notification will be triggered after each update.

Examples

Example 1:  

// create an object
var selState = app.selectionState( );
var listener = function() {
	alert('Back count:' + selState.backCount);
	//unregister the listener when no longer notification is needed.
	selState.OnData.unbind( listener );
};
//bind the listener
selState.OnData.bind( listener );

Example 2: Using AngularJS

Main script:
$scope.selState = app.selectionState( );
AngularJS template:
<button type="button" class="btn btn-default btn-xs" ng-click="selState.clearAll()" aria-label="Clear">
	<span class="glyphicon glyphicon-remove" aria-hidden="true"></span>
</button>

<li ng-repeat="sel in selState.selections">{{sel.fieldName}}: {{sel.qSelected}}
	<button type="button" class="btn btn-default btn-xs" ng-click="sel.field.clear()" aria-label="Lock">
		<span class="glyphicon glyphicon-remove" aria-hidden="true"></span>
	</button>
</li>

Did this information help you?

Thanks for letting us know. Is there anything you'd like to tell us about this topic?

Can you tell us why it did not help you and how we can improve it?