# WidgetMetadata Object
# Properties
Name | Type | Description |
---|---|---|
panels | WidgetMetadataPanel[] | An array of the widget's panels |
ignore | object | An object defining which dashboard filters are ignored by the widget |
# Ignored Widgets
The widget's ignore
declaration states which dashboard filters should be ignored by the widget.
Add dimension IDs to the dimensions
array to explicitly state which dimensions should be ignored, or set the all
property to true
to ignore all dashboard filters.
{
dimensions: [ "sales.product", "sales.city" ],
all: false
}
# Methods
# panel
Gets a widget's metadata panel by index, name or predicate
# Get panel by index
metadata.panel(index)
Arguments
Name | Type | Required | Description |
---|---|---|---|
index | integer | Yes | Index of panel to fetch |
Returns
Example
widget.metadata.panel(0);
# Get panel by name
metadata.panel(name)
Arguments
Name | Type | Required | Description |
---|---|---|---|
name | string | Yes | Name of panel to fetch |
Returns
Example
widget.metadata.panel('Categories');
# Get panel by predicate
metadata.panel(predicate)
Arguments
Name | Type | Required | Description |
---|---|---|---|
predicate | function | Yes | A function invoked for each panel, returning true for the desired panel to retrieve. |
Returns
Example
// Get the first panel with more than 1 item
widget.metadata.panel((p) => {
return p.items.length > 1;
});
# items
metadata.items([predicate])
Gets all of the widget's metadata items, optionally filtered by the predicate
function.
Arguments
Name | Type | Required | Description |
---|---|---|---|
predicate | function | No | A function invoked for each metadata item, returning true for the desired items to retrieve. |
Returns
Example
widget.metadata.items();
# filters
metadata.filters()
Gets an array of widget filters.
Arguments
N/A
Returns
Example
widget.metadata.filters();
# WidgetMetadataPanel Object
# Properties
Name | Type | Description |
---|---|---|
items | MetadataItem[] | The Metadata items contained in the panel |
# Methods
# item
Get a metadata item from the panel by index, GUID or predicate
# Get an item by index
panel.item(index)
Arguments
Name | Type | Required | Description |
---|---|---|---|
index | integer | Yes | Index of item to get |
Returns
Example
widget.metadata.panel(0).item(0);
# Get an item by GUID
panel.item(guid)
Arguments
Name | Type | Required | Description |
---|---|---|---|
guid | string | Yes | GUID of item to get |
Returns
Example
widget.metadata.panel(0).item('DA0A8-A06F-B07C-15E9');
# Get an item by predicate
panel.item(predicate)
Arguments
Name | Type | Required | Description |
---|---|---|---|
predicate | function | Yes | A function invoked for each item, returning true for the desired item to retrieve. |
Returns
Example
widget.metadata.panel(0).item((i) => {
return i.jaql.dim === '[Commerce.Brand ID]';
});
# push
panel.push(items)
Add one or more metadata items to the panel
Arguments
Name | Type | Required | Description |
---|---|---|---|
items | MetadataItem or MetadataItem[] | Yes | A metadata item or an array of metadata items to add |
Returns
N/A
Example
// add one item
widget.metadata.panel(0).push(item1);
// add multiple items
widget.metadata.panel(0).push([item1, item2]);
# isEmpty
panel.isEmpty()
Returns a response stating whether the panel is empty or not.
Arguments
N/A
Returns
boolean
Example
console.log(widget.metadata.panel(0).isEmpty());