Web AppBuilder for ArcGIS (Developer Edition)

WidgetManager class

The WidgetManager class is used to manage a widget for such things as loading, creating, and destroying a widget.

Example:

require(["jimu/WidgetManager"], function(WidgetManager) { 
  var wm = WidgetManager.getInstance();
});

Methods

getInstance()

A static method that returns the singleton instance of the WidgetManager object.

Return type: WidgetManager.

loadWidget(widgetJson)

Loads and creates a widget. If the widget, identified by widget ID, exists, the existing widget returns.

Parameters:

widgetJson: The widget JSON object configured in the app’s config.json file.

Return type: Deferred object. When the load succeeds, the widget instance object is resolved.

getWidgetById(widgetId)

Returns the widget identified by the widget ID. If the widget is not loaded, it returns undefined.

Parameters:

widgetId: The widget ID.

Return type: Widget instance object.

getWidgetsByName(widgetName)

Returns the widget identified by the widget name. If no widget is found, it returns an empty array.

Parameters:

widgetName: The widget name.

Return type: Widget object array.

getWidgetMarginBox(widget)

Returns the widget's margin box. It is useful when you want to put an off-panel widget at the correct position. This method calls the setPosition method, opens a widget, gets the domNode margin box of the widget, and closes the widget.

Parameters:

widget-ID or the widget instance.

Return type: Widget margin box object, which contains the following four properties:

  • l: Left
  • t: Top
  • w: Width
  • h: Height

getWidgetByLabel(widgetLabel)

Returns the widget identified by the widget label. If the widget is not loaded, the value of undefined is returned.

Parameters:

widgetLabel: The widget label.

Return type: Widget instance.

getAllWidgets

Returns all loaded widget objects.

Return type: Widget object array.

destroyAllWidgets

Destroys all loaded widget objects.

Return type: No return.

openWidget(widget)

Opens a loaded widget. It changes the widget state to open and calls the widget onOpen method. If the widget does not load, it does nothing.

Parameters:

widgetID or widget instance object.

Return type: No return.

maximizeWidget(widget)

Maximizes a loaded widget. It changes the widget window state to maximized and calls the widget onMaximize method. If the widget does not load, it does nothing.

Parameters:

widgetID or widget instance object.

Return type: No return.

minimizeWidget(widget)

Minimizes a loaded widget. It changes the widget window state to minimized and calls the widget onMinimize method. If the widget does not load, it does nothing.

Parameters:

widgetID or widget instance object.

Return type: No return.

normalizeWidget(widget)

Normalizes a loaded widget. It changes the widget window state to normal and calls the widget onNormalize method. If the widget is does not load, it does nothing.

Parameters:

widgetName: The widget name.

Return type: Widget object array.

closeWidget(widget)

Closes a loaded widget. It changes the widget state to closed and calls the widget onClose method. If the widget does not load, it does nothing.

Parameters:

widgetID or widget instance object.

Return type: No return.

destroyWidget(widget)

Destroys a loaded widget. If the widget does not load, it does nothing.

Parameters:

widgetID or widget instance object.

Return type: No return.

tryLoadWidgetConfig(widgetJson)

Loads the widget configuration.

  • If widgetJson has no config property, it tries to load the config.json file in the widget folder.
  • If the widgetJson.config file is a string, it tries to load the file that string points to.
  • If the widgetJson.config file is an object, the object will be resolved.

If the config version is older and the widget has VersionManager, it tries to run the upgrader function and returns the latest version of the config object.

Parameters:

widgetJson: The widget JSON object configured in the app’s config.json file.

Return type: Deferred object. When the load succeeds, the widget configuration object is resolved.

loadWidgetSettingPage(widgetJson)

Loads the widget setting page class and creates the setting page object. The created object is not cached.

Parameters:

widgetJson: The widget JSON object configured in the app’s config.json file.

Return type: Deferred object. When the load succeeds, the widget configuration object is resolved.


In this topic
  1. Methods