ViewerApiExtension Class

An extension that allows you to customize a visual part of the Web Dashboard.

Declaration

export class ViewerApiExtension extends DisposableObject implements ISupportOptionExtension<ViewerApiExtensionOptions>

Remarks

To configure the Web Dashboard’s visual part, refer to the ViewerApiExtensionOptions class that contains extension options.

Implements

Inherited Members

Inheritance

DisposableObject
ViewerApiExtension

constructor(dashboardControl)

Initializes a new instance of the ViewerApiExtension class.

Declaration

constructor(
    dashboardControl: DashboardControl,
    options?: ViewerApiExtensionOptions
)

Parameters

Name Type Description
dashboardControl DashboardControl

A Web Dashboard control that owns the extension.

options ViewerApiExtensionOptions

Properties

name Property

Specifies the unique extension name.

Declaration

name: string

Property Value

Type Description
string

The unique extension name. The return value is viewerApi.

Remarks

Use the viewerApi name in your applications so you can change the extension options when calling the control’s option method. Before v20.2 the extension name was viewer-api. You can use the old name only in the DashboardControl.findExtension method.

Warning

Do not change the unique name of the extension registered in the Web Dashboard to avoid exceptions.

off Property

Unsubscribes from the ViewerApiExtension’s events.

Declaration

off: EventSubscriber<ViewerApiExtensionEvents>

Property Value

Type Description
EventSubscriber<ViewerApiExtensionEvents>

An event subscription.

Remarks

The extension’s on and off methods help you subscribe to and unsubscribe from events:

// An event handler for the ItemWidgetOptionsPrepared event:
function onItemWidgetOptionsPrepared(args) {
    alert(args.itemName)
}
...
var viewerApiExtension = dashboardControl.findExtension('viewerApi');
// Subscribe to the ItemWidgetOptionsPrepared event:
if(viewerApiExtension) {
    viewerApiExtension.on('itemWidgetOptionsPrepared', onItemWidgetOptionsPrepared)
}
...
// Unsubscribe from the ItemWidgetOptionsPrepared event:
if(viewerApiExtension) {
    viewerApiExtension.off('itemWidgetOptionsPrepared', onItemWidgetOptionsPrepared)
}

on Property

Subscribes to the ViewerApiExtension’s events.

Declaration

on: EventSubscriber<ViewerApiExtensionEvents>

Property Value

Type Description
EventSubscriber<ViewerApiExtensionEvents>

An event subscription.

Remarks

The extension’s on and off methods help you subscribe to and unsubscribe from events:

// An event handler for the ItemWidgetOptionsPrepared event:
function onItemWidgetOptionsPrepared(args) {
    alert(args.itemName)
}
...
var viewerApiExtension = dashboardControl.findExtension('viewerApi');
// Subscribe to the ItemWidgetOptionsPrepared event:
if(viewerApiExtension) {
    viewerApiExtension.on('itemWidgetOptionsPrepared', onItemWidgetOptionsPrepared)
}
...
// Unsubscribe from the ItemWidgetOptionsPrepared event:
if(viewerApiExtension) {
    viewerApiExtension.off('itemWidgetOptionsPrepared', onItemWidgetOptionsPrepared)
}

requestUnderlyingData Property

Requests underlying data for the specified dashboard item.

Declaration

requestUnderlyingData: (itemName: string, args: RequestUnderlyingDataParameters, onCompleted: (result: ItemUnderlyingData) => void) => void

Property Value

Type Description
(itemName: string, args: RequestUnderlyingDataParameters, onCompleted: (result: ItemUnderlyingData) => void) => void

A lambda function that contains the component name of the dashboard item, the object containing parameters used to obtain the underlying data, and the object that references a method executed after the request is completed.

Methods

canClearMasterFilter(itemName) Method

Returns whether the specified master filter can be cleared in the current state.

Declaration

canClearMasterFilter(
    itemName: string
): boolean

Parameters

Name Type Description
itemName string

A string that specifies the component name of the master filter item.

Returns

Type Description
boolean

true, if the specified master filter can be cleared in the current state; otherwise, false.

canPerformDrillDown(itemName) Method

Returns whether drill down is possible in the current state of the specified dashboard item.

Declaration

canPerformDrillDown(
    itemName: string
): boolean

Parameters

Name Type Description
itemName string

A string that specifies the component name of the dashboard item.

Returns

Type Description
boolean

true, if drill down is possible in the current state of the specified dashboard item; otherwise, false.

canPerformDrillUp(itemName) Method

Returns whether drill up is possible in the current state of the specified dashboard item.

Declaration

canPerformDrillUp(
    itemName: string
): boolean

Parameters

Name Type Description
itemName string

A string that specifies the component name of the dashboard item.

Returns

Type Description
boolean

true, if drill up is possible in the current state of the specified dashboard item; otherwise, false.

canSetMasterFilter(itemName) Method

Returns whether master filtering can be applied in the current state of the specified master filter item.

Declaration

canSetMasterFilter(
    itemName: string
): boolean

Parameters

Name Type Description
itemName string

A string that specifies the component name of the master filter item.

Returns

Type Description
boolean

true, if master filtering can be applied in the current state of the specified master filter item; otherwise, false.

clearMasterFilter(itemName) Method

Clears the specified master filter item.

Declaration

clearMasterFilter(
    itemName: string
): void

Parameters

Name Type Description
itemName string

A string that specifies the component name of the master filter item.

Remarks

Use the ViewerApiExtension.setMasterFilter method to set master filter values.

The following code shows how to clear filter values for the Grid dashboard item:

dashboardControl.GetDashboardControl().findExtension('viewerApi').clearMasterFilter();
See Also

getAvailableActions(itemName) Method

Declaration

getAvailableActions(
    itemName: string
): Array<string>

Parameters

Name Type
itemName string

Returns

Type
Array<string>

getAvailableDrillDownValues(itemName) Method

Returns axis point tuples identifying elements that can be used to drill down in the specified dashboard item.

Declaration

getAvailableDrillDownValues(
    itemName: string
): Array<ItemDataAxisPointTuple>

Parameters

Name Type Description
itemName string

A string that is the component name of the dashboard item.

Returns

Type Description
Array<ItemDataAxisPointTuple>

An array of ItemDataAxisPointTuple objects identifying elements that can be used to drill down in the specified dashboard item.

getAvailableFilterValues(itemName) Method

Returns elements that can be selected in the master filter item’s current state (except Range Filter or Date Filter items).

Declaration

getAvailableFilterValues(
    itemName: string
): Array<ItemDataAxisPointTuple>

Parameters

Name Type Description
itemName string

A string that is the component name of the master filter item.

Returns

Type Description
Array<ItemDataAxisPointTuple>

An array of ItemDataAxisPointTuple objects identifying elements that can be selected in the current state of the master filter item.

Remarks

For Range Filter or Date Filter dashboard items, call the getCurrentRange(itemName) method to get the selected range.

getAvailablePredefinedRanges(itemName) Method

Returns names of the predefined ranges available for the specified Range Filter / Date Filter.

Declaration

getAvailablePredefinedRanges(
    itemName: string
): Array<string>

Parameters

Name Type Description
itemName string

A string that specifies a component name of the Range Filter / Date Filter dashboard items.

Returns

Type Description
Array<string>

An array of string values that are names of the available predefined ranges.

getCurrentDrillDownValues(itemName) Method

Returns the axis point tuple identifying the current drill-down state.

Declaration

getCurrentDrillDownValues(
    itemName: string
): ItemDataAxisPointTuple

Parameters

Name Type Description
itemName string

A string that is the component name of the dashboard item.

Returns

Type Description
ItemDataAxisPointTuple

An ItemDataAxisPointTuple object representing a set of axis points.

getCurrentFilterValues(itemName) Method

Returns axis point tuples identifying currently selected elements in the master filter item.

Declaration

getCurrentFilterValues(
    itemName: string
): Array<ItemDataAxisPointTuple>

Parameters

Name Type Description
itemName string

A string that is the component name of the master filter item.

Returns

Type Description
Array<ItemDataAxisPointTuple>

An array of ItemDataAxisPointTuple objects identifying elements that can be selected in the current state of the master filter item.

getCurrentPredefinedRange(itemName) Method

Declaration

getCurrentPredefinedRange(
    itemName: string
): string

Parameters

Name Type
itemName string

Returns

Type
string

getCurrentRange(itemName) Method

Returns the currently selected range in the specified Range Filter dashboard item.

Declaration

getCurrentRange(
    itemName: string
): RangeFilterSelection

Parameters

Name Type Description
itemName string

A string that specifies the component name of the Range Filter dashboard item.

Returns

Type Description
RangeFilterSelection

A RangeFilterSelection object that is the selected range.

Remarks

Use the getCurrentRange method after the dashboard item loads data. When the Range Filter or Date Filter has no data to display, the getCurrentRange method returns null.

getCurrentSelection(itemName) Method

Returns currently selected elements in the master filter item.

Declaration

getCurrentSelection(
    itemName: string
): Array<ItemDataAxisPointTuple>

Parameters

Name Type Description
itemName string

A string that specifies a component name of the master filter item.

Returns

Type Description
Array<ItemDataAxisPointTuple>

An array of ItemDataAxisPointTuple objects that identify currently selected elements.

getEntireRange(itemName) Method

Returns the visible range for the specified Range Filter dashboard item.

Declaration

getEntireRange(
    itemName: string
): RangeFilterSelection

Parameters

Name Type Description
itemName string

A string that specifies the component name of the Range Filter dashboard item.

Returns

Type Description
RangeFilterSelection

A RangeFilterSelection object that is the visible range.

getItemData(itemName) Method

Returns the client data for the specified dashboard item.

Declaration

getItemData(
    itemName: string
): ItemData

Parameters

Name Type Description
itemName string

A string that specifies the component name of the dashboard item.

Returns

Type Description
ItemData

An ItemData object that represents multidimensional data visualized in the dashboard item.

Remarks

View Example: Obtain a dashboard item's client data

getSelectedTabPage(tabContainerName) Method

Gets the selected page in the specified tab container.

Declaration

getSelectedTabPage(
    tabContainerName: string
): string

Parameters

Name Type Description
tabContainerName string

A string that is the tab container’s componentName property value.

Returns

Type Description
string

A string that is the tab page’s componentName property value.

getSelectedTabPageIndex(tabContainerName) Method

Gets the index of the selected page in the specified tab container.

Declaration

getSelectedTabPageIndex(
    tabContainerName: string
): number

Parameters

Name Type Description
tabContainerName string

A string that is the tab container’s componentName property value.

Returns

Type Description
number

A number that is the tab page’s index.

performDrillDown(itemName, value) Method

Performs a drill-down into the required element.

Declaration

performDrillDown(
    itemName: string,
    value: PrimitiveType | ItemDataAxisPointTuple
): void

Parameters

Name Type Description
itemName string

A string that specifies the component name of the dashboard item.

value PrimitiveType | ItemDataAxisPointTuple

An ItemDataAxisPointTuple object representing a set of axis points.

performDrillUp(itemName) Method

Performs a drill-up for the required element.

Declaration

performDrillUp(
    itemName: string
): void

Parameters

Name Type Description
itemName string

A string that specifies the component name of the dashboard item.

setMasterFilter(itemName, values) Method

Selects required elements by their values in the specified master filter item.

Declaration

setMasterFilter(
    itemName: string,
    values: MasterFilterValues
): void

Parameters

Name Type Description
itemName string

A string that specifies the component name of the master filter item.

values MasterFilterValues

Values that are used to select elements in the master filter item.

Remarks

Only dimension fields can be a part of the master filter values. To select a row, create a filter with unique values that unambiguously define this row.

The following code shows how to add filter values to the Grid dashboard item with Country and Sales Person dimensions:

var filterValues = [['UK', 'Anne Dodsworth'], ['USA', 'Andrew Fuller']];
dashboardControl.GetDashboardControl().findExtension('viewerApi').setMasterFilter("gridSalesByState", filterValues);

Use the ViewerApiExtension.clearMasterFilter(itemName) to clear filter values.

See Also

setPredefinedRange(itemName, dateTimePeriodName) Method

Selects a predefined range in the Range Filter dashboard item.

Declaration

setPredefinedRange(
    itemName: string,
    dateTimePeriodName: string
): void

Parameters

Name Type Description
itemName string

A string that specifies the component name of the Range Filter.

dateTimePeriodName string

A string that specifies the predefined range name.

Remarks

Use the setPredefinedRange method after the Range Filter has loaded data. When the Range Filter has no data to display, the setPredefinedRange method returns null.

setRange(itemName, range) Method

Selects the required range in the specified Range Filter / Date Filter dashboard item.

Declaration

setRange(
    itemName: string,
    range: RangeFilterSelection
): void

Parameters

Name Type Description
itemName string

A string that specifies the component name of the Range Filter / Date Filter.

range RangeFilterSelection

A RangeFilterSelection object that specifies a range to be selected.

Remarks

Use the setRange method after the Range Filter / Date Filter has loaded data. When the Range Filter / Date Filter has no data to display, the setRange method returns null.

setSelectedTabPage(tabPageName) Method

Selects the specified tab page by its component name.

Declaration

setSelectedTabPage(
    tabPageName: string
): void

Parameters

Name Type Description
tabPageName string

A string that is the tab page’s componentName property value.

setSelectedTabPageIndex(tabContainerName, index) Method

Selects the specified tab page by its index in the specified tab container.

Declaration

setSelectedTabPageIndex(
    tabContainerName: string,
    index: number
): void

Parameters

Name Type Description
tabContainerName string

A string that is the tab container’s componentName property value.

index number

A number that is the tab page’s index.

start Method

Contains code that is executed when you register the dashboard extension.

Declaration

start(): void

stop Method

Contains code that is executed when you unregister the dashboard extension.

Declaration

stop(): void

updateDashboardTitleToolbar Method

Declaration

updateDashboardTitleToolbar(): void

Remarks

The DashboardTitleToolbarUpdated event occurs before the dashboard title toolbar is updated. Use the updateDashboardTitleToolbar method to trigger the following event manually.

updateItemCaptionToolbar Method

Fires the ItemCaptionToolbarUpdated event for the specified item.

Declaration

updateItemCaptionToolbar(
    itemName?: string
): void

Parameters

Name Type Description
itemName string

A dashboard item name for which the event is fired.

Remarks

The ItemCaptionToolbarUpdated event occurs before the dashboard item’s caption toolbar is updated. Use the updateItemCaptionToolbar method to trigger the following event manually. If the itemName parameter is empty, the ItemCaptionToolbarUpdated event is fired for all dashboard items and groups.