Skip to main content

ResourceManager Class

A class containing methods used to manage dashboard control static content.

Declaration

export class ResourceManager

Methods

embedBundledResources Method

Integrates dashboard control’s resources in the document object model.

Declaration

static embedBundledResources(): void

Remarks

You don’t need to embed the control code inside the DOM structure forcibly. When you add at least one DashboardControl on the page, it creates a div element that generates the Web Dashboard on the HTML page. The control automatically embeds and dispose resources. If you have more that one control instance, the resources are added with the first control on the page and are disposed with the last control on the page.

If you call the embedBundledResources method, you should manually dispose resources to remove the generated markup from the page. For this, call the removeEmbeddedResources method.

registerIcon(icon) Method

Embeds an icon’s SVG definition onto the page.

Declaration

static registerIcon(
    icon: string | HTMLElement
): void

Parameters

Name Type
icon string | HTMLElement

Remarks

You can use the registerIcon method as an alternative variant to add an icon onto the page.

In your JavaScript code, declare a string variable and specify the icon’s definition.

var customItemIcon = '<svg id="customIconId" viewBox="0 0 24 24"><style type="text/css">.dx-dashboard-icon {fill:currentColor;}</style><path class="dx-dashboard-icon" d="M12 2 L2 22 L22 22 Z" /></svg>';

After that, pass the created variable as the registerIcon method’s parameter.

if(!!dashboardControl) {
  dashboardControl.registerIcon(customItemIcon);
}

Tip

See Predefined Colors for information on which color constants you can use to natively embed an icon in the Web Dashboard application.

removeEmbeddedResources Method

Remove dashboard control resources from the document object model.

Declaration

static removeEmbeddedResources(): void

Remarks

You don’t need to embed the control code inside the DOM structure forcibly. When you add at least one DashboardControl on the page, it creates a div element that generates the Web Dashboard on the HTML page. The control automatically embeds and dispose resources. If you have more that one control instance, the resources are added with the first control on the page and are disposed with the last control on the page.

If you call the embedBundledResources method, you should manually dispose resources to remove the generated markup from the page. For this, call the removeEmbeddedResources method.

setLocalizationMessages(localizationMessages) Method

Allows you to define dashboard localization strings.

Declaration

static setLocalizationMessages(localizationMessages: {
    [localizationStringId: string]: string;
}): void

Parameters

Name Type Description
localizationMessages {[localizationStringId: string]: string}

An object in a {string : string} format, where the first string is a localization string id, and the second string is a localization message.

Remarks

The code snippet below shows how to change a localization message used in the Export To button’s tooltip.

<head>
    <!-- ...-->
    <script>
        DevExpress.Dashboard.ResourceManager.setLocalizationMessages({ "DashboardStringId.ActionExportTo": "Custom Text for Export Button" });
        window.onload = function () {            
            var dashboardControl = new DevExpress.Dashboard.DashboardControl(document.getElementById("web-dashboard"), {
                endpoint: "https://demos.devexpress.com/services/dashboard/api"                
            });
            dashboardControl.render();
        };
    </script>
</head>