Widget

App.Widget. Widget

Represents one widget in a dashboard.

Events

Name Fired when
show content of widget becomes visible, e.g. after expading the widget
hide content of widget is no longer visible, e.g. after collapsing the widget
remove widget is removed from the dashboard
resizeStart starting to resize widget
resize widget is resize, invocations are throttled. Mind performance!
resizeStop resize of widget has stopped

Read more about event handling.

Constructor

new Widget(options, customizations, dashboard)

See:
  • App.Widget

Widget constructor

Parameters:
Name Type Description
options Object

Widget options

customizations Object

customizations associated with this widget

dashboard Dashboard

Dashboard the widget contains to

Methods

_getContentElement() → {jQuery}

Return the JQ widget content instance, which always contains the widget data

Returns:

The Widget content instance itself

Type
jQuery

_setLoadFail()

Updates widget load status to fail and triggers load complete event

addChangeListener(fn, preFilterFn) → {*}

Parameters:
Name Type Description
fn
preFilterFn
Returns:
Type
*

addCreateListener(fn, preFilterFn) → {*}

Parameters:
Name Type Description
fn
preFilterFn
Returns:
Type
*

addWidgetCloseListener()

Deprecated:
  • Use on(), off() APIs instead

closeSidepanel()

Closes the sidepanel

collapse()

Collapses the widget

destroy()

disableResize()

Disable and hide resize

editWidget()

Opens the end user created widget in edit mode

enableResize()

Enable and show resize

expand()

Expands the widget

forceRefresh()

Refresh the widget - after first also refreshing its parent Dashboard

forceRefreshWidgetAndToolbar() → {*}

Returns:
Type
*

fullscreen()

Toggle fullscreen.

getCollectionName()

Gets the collection name return {string} Name of the collection

getContentCustomization() → {Object}

Queries widget content (e.g. datatable, chart etc.) to get customization. Widget Content should return full customization state

Returns:
Type
Object

getContextObjectIds() → {Array}

Returns an Array of context object ids associated with this widget

Returns:

list of context object ids or an empty array

Type
Array

getContextRelIds() → {Array}

Returns an Array of context relationship ids associated with this widget

Returns:

list of context relationship ids or an empty array

Type
Array

getFirstContextOrPageObjectId() → {String}

Returns first context object id associated with this widget. Defaults to page level object id

Returns:

context object id or page level object id or undefined

Type
String

getForceReload() → {boolean}

Return the forceReload setting from the widget configuration options

Returns:
Type
boolean

getHeaderHeight()

Get the widgets header height in px.

getId() → {String|undefined}

Returns widget id for this widget, usually configured in XML

Returns:
Type
String | undefined

getMode()

Deprecated:
  • 2019.2.0 Implement this in your Widget to define the available Modes

Returns the mode. By default it returns "VIEW" but can be overridden in Widget implementation.

getType()

Gets type of the widget return {string} type of this widget. One of App.Widget.Types

getWidgetHeightInPixels()

Get the widgets height in px.

getWidgetId() → {string}

Return the widget id

Returns:
Type
string

getWidgetInner() → {*}

Returns:
Type
*

getWidgetTitle() → {*}

Returns:
Type
*

getWidgetWidth() → {number}

Return the widget width

Returns:
Type
number

handleDataUpdate(updatedData)

Invoked when new data is available for this widget

Parameters:
Name Type Description
updatedData

new data for this widget

handleLoadError()

Handles errors on widget loading.

handleSearch(query) → {promise}

handles search criteria

Parameters:
Name Type Description
query array

search criteria *

Returns:

search promise

Type
promise

hasFixedHeight() → {boolean}

Returns:
Type
boolean

hideContent()

hideExpandIcon()

Hides the expand icon.

hideMessage($widgetopt)

Hide the displayed message in a container if the container is not provided, then displayed message in the widget will be hide.

Parameters:
Name Type Attributes Description
$widget jQuery <optional>

The container in which displayed message will be hide.

isCollapsed() → {boolean}

Returns true if the widget is collapsed

Returns:
Type
boolean

isContentCustomizable() → {boolean}

Returns true if the widget content (i.e. data table, chart etc.) is customizable

Returns:
Type
boolean

isCustomizable() → {boolean}

Returns true if this widget is customizable

Returns:

true if customizable, false otherwise

Type
boolean

isDrilldown() → {*|boolean}

Returns:
Type
* | boolean

isEditMode()

Returns true if widget is in EDIT mode, false otherwise.

isExpanded() → {boolean}

Returns true if the widget is expanded

Returns:
Type
boolean

isExpandedInCustomization() → {boolean}

Return the user preference whether a widget is expanded or not

Returns:
Type
boolean

isFullscreen() → {boolean|*}

Returns:
Type
boolean | *

isGrouped() → {boolean}

Return true if widget will render grouped table else false.

Returns:
Type
boolean

isHeaderless() → {boolean}

Returns:
Type
boolean

isLoaded() → {boolean}

Returns:
Type
boolean

isLocked()

Check if widget is locked, return true if locked.

isPlaceholder() → {boolean}

Returns:
Type
boolean

isViewMode()

Returns true if widget is in VIEW mode, false otherwise.

loadRelatedWidgets(relatedWidgetsInfo)

Updates related widgets in this widget's dashboard

Each entry in the input object consists of a key (i.e. 'widget-id') of the widget to be updated and value (an object with list of objectIds as the key) that will serve as input for widget loader.

Example
widget.loadRelatedWidgets({
    'ebom': {
        'objectIds': ['12534.36095.35288.16395', '12534.36095.65377.15060']
    },
    'artwork': {
        'objectIds': ['12534.36095.35288.16395', '12534.36095.65377.15060']
    }
});
Parameters:
Name Type Description
relatedWidgetsInfo Object.<string, Object.<string, Array.<string>>>

off(event, handler)

Remove a subscription.

Parameters:
Name Type Description
event String

Event to remove subscription from

handler function

Callback to remove

on(event, handler)

Subscribe to an event.

Parameters:
Name Type Description
event String

Event to subscribe to

handler function

Callback function

onCustomizationUpdate(customization)

Updates widget's layout settings locally

Parameters:
Name Type Description
customization

custom/ new layout positions

onDeselect(objectIds)

Parameters:
Name Type Description
objectIds

onLoadComplete(callback)

Register callback that will be invoked once widget is loaded.

Parameters:
Name Type Description
callback function

to be invoked when widget is loaded

onPostRender(context, postRenderer)

Called when the widget on postRender from the widget content. Will set correct 'this' for configured toolbars and execute provided post renderer.

Parameters:
Name Type Description
context Object

'this' of the widget content

postRenderer String

PostRender function configured for the widget content.

onSelect(objectIds)

Parameters:
Name Type Description
objectIds

openSidepanel()

Opens the sidepanel

performSearch($panel, e,)

Performs an search/filter on the widget, of any type that has performSearch implementation

Parameters:
Name Type Description
$panel

reference to the panel enclosing this

e, KeyUpEvent

keyupevent fired from the search input. Filtering will be based on the value of the input element

refresh()

Refresh the widget by running the widgets onInit again.

refreshToolbar() → {*}

Returns:
Type
*

refreshToolbarAndWidget() → {*}

Returns:
Type
*

refreshWidgetAndToolbar() → {*}

Returns:
Type
*

remove(done, fadeOutTime)

Removes the widget from the dashboard. This is an internal function and should not be called directly. Use App.Dashboard.removeWidget(widget) instead.

Parameters:
Name Type Default Description
done function

Callback when widget is removed (Optional)

fadeOutTime Number 400

The time in milliseconds for the fade out animation (Optional)

removeChangeListener(callback)

Parameters:
Name Type Description
callback

removeCreateListener(callback)

Parameters:
Name Type Description
callback

replace(id) → {App.Widget}

Replaces the widget with the widget configuration passed in. Height and position will be copied from the original widget

Parameters:
Name Type Description
id String

The id of the widget to replace the current widget

Returns:

newly added widget instance

Type
App.Widget

resetCustomizations()

Removes any Widget-level customizations persisted on the server, and refreshes the Widget afterwards

saveContentCustomization()

Saves customization on server

setBadge(badgeText)

See:
  • setBadgeFiltered

Set the badge in the widget header.

Parameters:
Name Type Description
badgeText Number | String

will be displayed as a badge

setBadgeFiltered(matches, total)

Sets badge on the widget in the for "matches / total"

Parameters:
Name Type Description
matches
total

setContextObjectIds(objectIds)

Sets the Array of context object ids associated with this widget

Parameters:
Name Type Description
objectIds Array

of object ids

Returns:

The Widget instance itself

setExpanded()

Sets expanded to true or false

setExpandIcon()

Sets the expand icon up or down

setForceRelaod()

Set the forceReload setting to the widget configuration options

setHeight(height, minHeight)

Set the height of the widget

Parameters:
Name Type Description
height
minHeight

setLoadSuccess()

Updates widget load status to success and triggers load complete event

setLocked()

Sets if widget is locked.

setTitle(title)

Sets widget title

Parameters:
Name Type Description
title String

title for widget

shouldHideContentDuringResize() → {boolean}

If widget should hide content while resizing

Returns:
Type
boolean

showContent()

showEmptyMessage()

Shows empty widget message

showExpandIcon()

Shows the expand icon.

showMessage(message, $widgetInneropt)

Display the message in a container if the container is not provided, then message will be displayed in the widget.

Parameters:
Name Type Attributes Description
message string

The message which will be displayed inside the container.

$widgetInner jQuery <optional>

The container in which message will be displayed.

startLoader()

Starts the widget loader

stopLoader()

Stops the widget loader

toggleExpand()

Toggle expand.

toggleHeaderActions(mobileMode)

Toggles header actions visibility depending on whether dashboard is in single column mode

Parameters:
Name Type Description
mobileMode boolean

true if single column mode, false otherwise

toggleLock()

Toggles widget's locking state.

toggleSidepanel()

Toggles the sidepanel

updateServerSideBean()

For client side widget customization, sync server bean with the changes applied at the client side.