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

How to: Implement Save As and Delete Functionality for the ASP.NET Web Forms Dashboard Control

  • 4 minutes to read

This example demonstrates how to implement custom extensions to add the “Save As” and “Delete” menu items to the Web Dashboard’s UI.

  • 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

View Example: Web Forms Dashboard - How to implement Save As and Delete functionality by creating custom extensions

// Creates and implements a custom SaveAsDashboardExtension class.

function SaveAsDashboardExtension(dashboardControl) {
    this._dashboardControl = dashboardControl;
    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.newName = ko.observable("New Dashboard Name");
}

SaveAsDashboardExtension.prototype.saveAs = function () {
    if (this.isExtensionAvailable()) {
        this._toolbox.menuVisible(false);
        this._newDashboardExtension.performCreateDashboard(this.newName(), this._dashboardControl.dashboard().getJSON());
    }
};

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

SaveAsDashboardExtension.prototype.start = function () {
    this._toolbox = this._dashboardControl.findExtension("toolbox");
    this._newDashboardExtension = this._dashboardControl.findExtension("create-dashboard");

    if (this.isExtensionAvailable())
        this._toolbox.menuItems.push(this._menuItem);
};

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