Excerpt |
---|
The custom widgets JavaScript API provides a number of properties and methods. Some of these are mostly used to access data, but others are explicitly provided as extension points to overwrite. |
Table of Contents
Table of Contents |
---|
outline | true |
---|
exclude | Table of Contents |
---|
|
...
The options for each composed widget depend on the widget type. If a widget requires one or more facets to visualize, the facets configuration should be passed in as shown in example above.
Widgets.Search
Rendering
itemTemplate
Specifies that a custom HTML template for each item should be used instead of the default one. Any of the custom templates uploaded with the custom widget can be assigned to this property directly.
Expand |
---|
|
Code Block |
---|
| afterInitialize: function () {
this.itemTemplate = this.customTemplates['myTemplate.html'];
}, |
|
getItemTemplateParams
widget.getItemTemplateParams()
If implemented, and if itemTemplate is defined, the returned value of getItemTemplateParams() will be passed onto the HTML side.
Expand |
---|
|
Code Block |
---|
| getItemTemplateParams: function () {
return {
external_id: 1234,
};
}, |
|
set()
Dashboard State
The dashboard state is accessible in the widget using the widget.dashboard.state
property. This model is the recommended way for custom widgets to talk to each-other. The dashboard state is a Backbone.js model though without persistence.
...
Expand |
---|
|
Code Block |
---|
| onStateChange: function () {
if (this.dashboard.state.get('additionalInfo')) {
this.$el.addClass('additional-info-requested');
}
}, |
|
state.set(attribute, value)
state.set(attributes)
...