ASPxDashboard.CustomJSProperties Event

Enables you to supply any server data that can then be parsed on the client.

Namespace: DevExpress.DashboardWeb

Assembly: DevExpress.Dashboard.v18.1.Web.WebForms.dll

Declaration

public event CustomJSPropertiesEventHandler CustomJSProperties
Public Event CustomJSProperties As CustomJSPropertiesEventHandler

The event handler receives an argument of the CustomJSPropertiesEventHandler type.

Sometimes, it is necessary to obtain server information on the client side. The CustomJSProperties event enables you to declare temporary client properties to store the necessary information. Once declared, a property can be accessed on the client using common syntax.

Add new properties via the event parameter's Properties property, which represents a collection of property names and their values. You have to add "cp" prefix to custom property names, in order to avoid rewriting the base properties. The code snippet below provides an illustration of this:

protected void ASPxDashboard1_CustomJSProperties(object sender, 
    DevExpress.Web.CustomJSPropertiesEventArgs e) {
    e.Properties.Add("cpWebDashboardWorkingMode", ASPxDashboard1.WorkingMode.ToString());
}

The CustomJSProperties event is raised on callbacks. You may check for this to prevent a variable from unnecessary initialization:

if (!IsCallback) {
    e.Properties.Add("cpWebDashboardWorkingMode", ASPxDashboard1.WorkingMode.ToString());
}

Then, you can obtain a custom property's value via the client object's cpMyProperty:

function(s, e) {
      alert("ASPxDashboard works in the following mode: "+webDashboard.cpDesignerWorkingMode);
}

On the server, it can be accessed by means of the ASPxDashboardViewer.JSProperties property.

ASPxDashboard1.JSProperties["cpWebDashboardWorkingMode"] = "AnyStringValue";

Examples

This example demonstrates how to export a dashboard displayed in ASPxDashboard on the server side using the ASPxDashboardExporter class. The following API is used to implement this capability.

function initializeControls() {
    $("#buttonContainer").dxButton({
        text: "Export to PDF",
        onClick: function (param) {
            var selectedDashboardID = webDashboard.GetDashboardId();
            var dashboardState = webDashboard.GetDashboardState();
            var parameters = selectedDashboardID + "|" + dashboardState;
            webDashboard.PerformDataCallback(parameters, null);
        }
    });

    $("#selectBox").dxSelectBox({
        dataSource: getDashboardIDs(),
        value: getDashboardIDs()[0],
        onValueChanged: function (param) {
            webDashboard.LoadDashboard(param.value);
        }
    });
}

function getDashboardIDs() {
    return webDashboard.cpGetDashboardIDs;
};

function dashboardExportedSuccess(args) {
    DevExpress.ui.notify('A dashboard was exported to ' + args.result, 'success', 5000);
};