Skip to main content
A newer version of this page is available. .

Extensions Overview

  • 7 minutes to read

You can use extensions to customize the HTML JavaScript Dashboard. The extension is an independent JavaScript module/class that provides specific functionality to the control.

This topic explains how to access the existing extensions, customize them, or create new extensions.

Get Underlying DashboardControl

You can customize the Web Dashboard before the underlying client part is rendered. For this, you need to get access to the DashboardControl instance. Use the BeforeRender event to configure the underlying part for wrappers (Web Forms, MVC, and ASP.NET Core controls). Refer to the following topics to learn how to obtain the DashboardControl:

For the HTML JavaScript control, configure the control before you call the render method:

window.onload = function () {
    var dashboardControl = = new DevExpress.Dashboard.DashboardControl(document.getElementById("web-dashboard"), {
        // Here you configure the control's options.
    });    
    // Here you can customize a control.

    dashboardControl.render();
}

Add or Remove Existing Extensions

To access all the enabled extensions, use the DashboardControl.extensions property that returns an array of objects. Each object implements the IExtension interface. The table below lists the Web Dashboard’s commonly used extensions:

Extension

Description

ToolboxExtension

The Web Dashboard Toolbox extension that provides access to the dashboard menu and allows you to add dashboard items, as well as undo or repeat user actions.

DashboardParameterDialogExtension

A Web Dashboard extension that is the Dashboard Parameters dialog.

DashboardExportExtension

A Web Dashboard extension that allows you to export dashboards and dashboard items.

ViewerApiExtension

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

MobileLayoutExtension

A Web Dashboard extension that allows you to enable a mobile layout for phones.

See the DevExpress.Dashboard.Designer module to find all available extensions.

Each extension exposes the IExtension.name property which returns an extension’s unique name. Use this name to access the extension.

To disable an extension, pass its name (IExtension.name) to the DashboardControl.unregisterExtension method. The code below shows how to disable the Web Dashboard’s export functionality:

function onBeforeRender(sender) {
    // ...
    var dashboardControl = sender.GetDashboardControl();
    dashboardControl.unregisterExtension("dashboard-export");
}

Note that some extensions (for instance, DashboardPanelExtension) are disabled. The code below shows how to use the DashboardControl.registerExtension method to enable the Dashboard Panel:

function onBeforeRender(sender) {
    // ...
    var dashboardControl = sender.GetDashboardControl();
    dashboardControl.registerExtension(new DevExpress.Dashboard.DashboardPanelExtension(dashboardControl));
}

Customize Existing Extension

To configure the registered extension, use the DashboardControl.findExtension method to obtain its instance and pass the IExtension.name property value as a method parameter.

The code sample below demonstrates how to use the ToolboxExtension.removeMenuItem method to obtain the ToolboxExtension and remove the New… command from the dashboard menu:

function onBeforeRender(sender) {
    var dashboardControl = sender.GetDashboardControl();
    var toolboxExtension = dashboardControl.findExtension("toolbox");
    toolboxExtension.removeMenuItem("create-dashboard");
}

Example: How to Add Save As and Delete Functionality to the Web Dashboard

This example demonstrates how to add the “Save As” and “Delete” menu items to the Web Dashboard’s UI by implementing the corresponding custom extensions:

  • The “Save As” menu item allows end-users to save the current dashboard with a new name.
  • The “Delete” menu item deletes the opened dashboard from the dashboard storage.

The image below shows the result of the extensions implementation.

wdd-custom-extension-save-as.png

// Creates and implements a custom SaveAsDashboardExtension class.

function SaveAsDashboardExtension(dashboardControl) {
    var _this = this;
    this._control = dashboardControl;
    this._toolbox = this._control.findExtension("toolbox");
    this._newDashboardExtension = this._control.findExtension("create-dashboard");
    this._menuItem = {
        id: "dashboard-save-as",
        title: "Save As...",
        template: "dx-save-as-form",
        selected: ko.observable(true),
        disabled: ko.computed(function () { return !dashboardControl.dashboard(); }),
        index: 112,
        data: _this
    };
    this.saveAs = function () {
        if (this.isExtensionAvailable()) {
            this._toolbox.menuVisible(false);
            this._newDashboardExtension.performCreateDashboard(this.newName(), this._control.dashboard().getJSON());
        }
    };
    this.newName = ko.observable("New Dashboard Name");
}

SaveAsDashboardExtension.prototype.isExtensionAvailable = function () {
    return this._toolbox !== undefined && this._newDashboardExtension !== undefined;
}

SaveAsDashboardExtension.prototype.start = function () {
    if (this.isExtensionAvailable())
        this._toolbox.menuItems.push(this._menuItem);
};
SaveAsDashboardExtension.prototype.stop = function () {
    if (this.isExtensionAvailable())
        this._toolbox.menuItems.remove(this._menuItem);
}
See Also