Examples
dashboard.getFeature('Canvas').getContent(<widgetId>)
dashboard.getFeature('Canvas').findContent()
Methods
addContent(options, transactionTokenopt) → {Promise.<ContentAPI>}
Adds content with the specified spec.
Parameters:
Name | Type | Attributes | Description | |||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
options |
Object | Contains the options for adding content to this contentApi. Properties
|
||||||||||||||||||||||
transactionToken |
TransactionToken |
<optional> |
Optional transaction token. |
Returns:
Promise resolved with the new content instance.
- Type
- Promise.<ContentAPI>
findContent(selector) → {Array.<ContentAPI>}
Returns a list of content that matches the provided selector.
Parameters:
Name | Type | Description | |||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
selector |
Object | Selector object; returns all widgets if undefined. Properties
|
Returns:
Array of content
- Type
- Array.<ContentAPI>
Example
content.findContent({
properties: {
title: 'My page'
}
});
content.findContent({
type: 'page'
});
getChildren() → {Array.<ContentAPI>}
Returns the children content.
Returns:
Array of contents
- Type
- Array.<ContentAPI>
getContainer() → {ContentAPI}
Returns the parent container.
Returns:
Content container
- Type
- ContentAPI
getContent(id) → {ContentAPI}
Returns the content that matches the given ID.
Parameters:
Name | Type | Description |
---|---|---|
id |
String | ID of the content |
Returns:
- Type
- ContentAPI
getFeature() → {Promise}
Returns a content-level feature. Features are extensions to the widget.
Parameters:
Name | Type | Description |
---|---|---|
featureId[.type |
String | featureId is the ID of the feature to get, while .type is the type of the feature. |
Returns:
Promise resolved with the feature or with undefined, if the feature does not exist.
- Type
- Promise
Example
content.getFeature('state') will return a public renderState API.
content.getFeature('state.internal') will return a private renderState API.
getId() → {String}
Returns the internal ID of the widget.
Returns:
Internal ID of the widget
- Type
- String
getPropertiesNameList() → {Array.<String>}
Returns an array of property names.
Returns:
Array of property objects
- Type
- Array.<String>
getPropertyLayoutList() → {Array.<Object>}
Returns a list of layout and properties used to render the properties UI.
Returns:
Array of layout and properties used to render the properties UI.
- Type
- Array.<Object>
getPropertyList() → {Array.<Object>}
get the list of all properties
Returns:
- Type
- Array.<Object>
getPropertyValue(name) → {Object}
Returns the value of a property.
Parameters:
Name | Type | Description |
---|---|---|
name |
String | Name of the property |
Returns:
Value of the property
- Type
- Object
getType() → {String}
Returns the type of the canvas content.
Returns:
Type of the canvas content
- Type
- String
off(eventName, handler, context)
Unregisters an event handler that was registered with ContentAPI#on
.
Parameters:
Name | Type | Description |
---|---|---|
eventName |
String | Name of the dashboard event |
handler |
function | Event handler to be called when the event occurs. |
context |
object | Context of the event |
on(name, handler) → {Object}
Register a content event handler.
Parameters:
Name | Type | Description |
---|---|---|
name |
String | Event name |
handler |
function | Event handler |
Returns:
Object that has a remove function to remove the event handler.
- Type
- Object
Example
content.on('all', (event) => { console.log(event); });
content.on('change:selections', (event) => { console.log(event.info.events); });
content.on('change:selections:clearAll', (event) => { console.log(event); });
removeContent(id, transactionTokenopt)
Removes the content with the specified ID.
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
id |
String | ID of the content |
|
transactionToken |
TransactionToken |
<optional> |
Optional transaction token |
setFeatureEnabled(featureId, isEnabled)
Determines whether a content-level feature is enabled or disabled at runtime.
Parameters:
Name | Type | Description |
---|---|---|
featureId |
String | ID of the feature to update |
isEnabled |
Boolean | Set to true to enable the feature. Default is true. |
setPropertyValue(name, value, options)
Sets the value of a property.
Parameters:
Name | Type | Description |
---|---|---|
name |
String | Name of the property to set |
value |
Object | Value to set |
options |
SetOptions |