...
A Backbone.js model that represents the currently rendered dashboard. See dashboard statestore for the main usage of this model.
...
Expand | |||||
---|---|---|---|---|---|
| |||||
This is an example that extends the facets table with an additional click handler.
See dashboard statestore for information on the state store property being used here. |
...
onStoreChange
widget.onStateChangeonStoreChange(model, options)
Status colour Blue title Extend
Called when a state store variable changes (see Dashboard StateStore).
The model
argument can be used to access the exact property or properties that have changed by accessing model.changed
. That property is a hash containing all the attributes that changed in the last set
call.
...
Expand | |||||
---|---|---|---|---|---|
| |||||
|
Dashboard
...
Store
The dashboard state store is accessible in the widget using the widget.dashboard.state
propertystore
property (usually this.dashboard.store
). This model is the recommended way for custom widgets to talk to each-other. The dashboard state store is a Backbone.js model though without persistence.
Custom widgets should implement the onStateChange onStoreChange method to listen for changes to the statestore.
Architecture
A good example for when to use the state store is when there are two widgets on a dashboard that have to communicate with each-other.
For example a navigation widget can be implemented which presents the user with a number of menu options. When clicking on one of the options, the state store is updated by setting a attribute. A second widget reacts to that state store value and changes the content to be displayed depending on the set attribute.
Methods
get()
statestore.get(attribute)
Get the current value of the state store attribute.
Expand | |||||
---|---|---|---|---|---|
| |||||
|
set()
statestore.set(attribute, value)
statestore.set(attributes)
Set one attribute to the given value or - in the secondary form - update all the key/value pairs from the hash.
If any attribute changes, a change
event is triggered. The easiest way to subscribe to those in the widget is by implementing the onStateChange onStoreChange method.
Expand | |||||
---|---|---|---|---|---|
| |||||
|
...