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

ASPxDashboard.CustomJSProperties Event

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

Namespace: DevExpress.DashboardWeb

Assembly: DevExpress.Dashboard.v20.2.Web.WebForms.dll

NuGet Package: DevExpress.Web.Dashboard

Declaration

public event CustomJSPropertiesEventHandler CustomJSProperties

Event Data

The CustomJSProperties event's data class is CustomJSPropertiesEventArgs. The following properties provide information specific to this event:

Property Description
Properties Gets a collection of temporary client properties.

Remarks

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 ASPxDashboard.JSProperties property.

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

Example

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.

View Example

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);
};
See Also