QSelectionState
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.
Version history
Version state | Details |
---|---|
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
$scope.selState = app.selectionState( );
<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>