Skip to main content

ASPxClientTreeView.ExpandedChanged Event

Fires on the client side after a node’s expansion state has been changed by end-user interaction.

Declaration

ExpandedChanged: ASPxClientEvent<ASPxClientTreeViewNodeEventHandler<ASPxClientTreeView>>

Event Data

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

Property Description
node Gets a node object related to the event.

Remarks

Write a ExpandedChanged event handler to perform specific actions on the client side each time a node’s expansion state has been changed by end-user interaction. You can use the event parameter’s ASPxClientTreeViewNodeEventArgs.node property to identify the node which has been expanded or collapsed. If a node’s expansion state has been changed programmatically, the ExpandedChanged event does not fire.

Example

The code below demonstrates how you can define node images and change them, when expanding and collapsing nodes on the client side.

using DevExpress.Web.ASPxTreeView;

public partial class _Default : System.Web.UI.Page {
    protected void Page_Load(object sender, EventArgs e) {
       DataBind();
       DefineImages(ASPxTreeView1.Nodes);
    }
    protected void DefineImages(TreeViewNodeCollection nodes) {
        foreach (TreeViewNode node in nodes) {
            if (node.Nodes.Count > 0) {
                node.Image.Url = "~/Images/closed_folder.png";
                DefineImages(node.Nodes);
            }
            else {
                node.Image.Url = "~/Images/file.png";
            }
        }
    }
}
See Also