Back to Devexpress

ASPxTreeList.CustomJSProperties Event

aspnet-devexpress-dot-web-dot-aspxtreelist-dot-aspxtreelist-db5eee24.md

latest3.6 KB
Original Source

ASPxTreeList.CustomJSProperties Event

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

Namespace : DevExpress.Web.ASPxTreeList

Assembly : DevExpress.Web.ASPxTreeList.v25.2.dll

NuGet Package : DevExpress.Web

Declaration

csharp
public event TreeListCustomJSPropertiesEventHandler CustomJSProperties
vb
Public Event CustomJSProperties As TreeListCustomJSPropertiesEventHandler

Event Data

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

PropertyDescription
PropertiesGets a collection of temporary client properties. Inherited from CustomJSPropertiesEventArgs.

Remarks

In some instances, it is necessary to obtain server information on the client. The CustomJSProperties event enables you to declare temporary client properties. These properties can hold arrays, hashtables, etc. Once declared, a property can be accessed on the client.

csharp
protected void ASPxTreeList1_CustomJSProperties(object sender,
TreeListCustomJSPropertiesEventArgs e) {
    // Scalar value
    e.Properties["cpScalar"] = "my value";

    // Nested arrays
    e.Properties["cpNestedArrays"] = new object[] { 
        "value",
        null,
        new string[] { "name1", "name2" }};

    // Hashtable
    Hashtable hash = new Hashtable();
    hash.Add("key", "value");
    e.Properties["cpHash"] = hash;
}

To add new properties, use the event parameter’s Properties property, which represents a collection of property names and their values. The only requirement is that property names must begin with the ‘cp’ prefix, to avoid rewriting the ASPxGridView base properties.

The CustomJSProperties event is also raised on callbacks. To prevent a temporary client property from being initialized on a callback, do the following:

csharp
protected void ASPxTreeList1_CustomJSProperties(object sender,
DevExpress.Web.ASPxTreeList.TreeListCustomJSPropertiesEventArgs e) {
    if (!IsCallback) {
        e.Properties["cpPageIndex"] = ASPxTreeList1.PageIndex;
    }
}

Note

Typically, using a specifically introduced ASPxTreeList.JSProperties property might be more convenient and efficient than handling the CustomJSProperties event, which is mostly declared for backward compatibility.

Concept

How to Access Server Data on the Client Side

See Also

JSProperties

Passing Values from the Server to the Client

Tree List

ASPxTreeList Class

ASPxTreeList Members

DevExpress.Web.ASPxTreeList Namespace