Skip to main content

ASPxClientTreeList.NodeExpanding Event

Fires before a node is expanded.

Declaration

NodeExpanding: ASPxClientEvent<ASPxClientTreeListNodeEventHandler<ASPxClientTreeList>>

Event Data

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

Property Description
cancel Gets or sets a value indicating whether the action which raised the event should be canceled.
htmlEvent Provides access to the parameters associated with the ASPxClientTreeList.NodeClick and ASPxClientTreeList.NodeDblClick events.
nodeKey Gets the processed node’s key value.

Remarks

Handle the NodeExpanding event to specify whether the node is allowed to be expanded. To cancel this action, set the event parameter’s cancel property to true.

This example below demonstrates how to configure the ASPxTreeList so that only one child node is expanded at a time.

function OnNodeExpanding(s, e) {
    s.PerformCallback(e.nodeKey);
    e.cancel = true;
}
<dx:ASPxTreeList ID="ASPxTreeList1" runat="server" DataSourceID="AccessDataSource1"
    AutoGenerateColumns="False" KeyFieldName="EmployeeID" ParentFieldName="ReportsTo"
    OnCustomCallback="ASPxTreeList1_CustomCallback">
    <ClientSideEvents NodeExpanding="OnNodeExpanding" />
    <Columns>
        <dx:TreeListTextColumn FieldName="LastName"/>
        <dx:TreeListTextColumn FieldName="FirstName" />
    </Columns>
</dx:ASPxTreeList>
protected void ASPxTreeList1_CustomCallback(object sender, TreeListCustomCallbackEventArgs e) {
    ASPxTreeList1.CollapseAll();
    TreeListNode node = ASPxTreeList1.FindNodeByKeyValue(e.Argument);
    while (node.ParentNode != null) {
        node.Expanded = true;
        node = node.ParentNode;
    }
}

To learn more, see Expanding and Collapsing Nodes.

See Also