Skip to main content

ASPxClientTreeView.GetNode(index) Method

Returns a node with the specified index within the ASPxTreeView’s node collection.

Declaration

GetNode(
    index: number
): ASPxClientTreeViewNode

Parameters

Name Type Description
index number

The zero-based index of the node.

Returns

Type Description
ASPxClientTreeViewNode

The node with the specified index within the ASPxTreeView’s node collection.

Remarks

Use the ASPxClientTreeView.GetNode method to get a client node object with the specified index within the ASPxTreeView’s node collection.

The ASPxClientTreeView.GetNodeCount method returns the number of zero level nodes. Decrement this number by one to get the upper available value that you can pass to the ASPxClientTreeView.GetNode method. This method returns null if you pass an invalid index to the parameter.

You can use the ASPxClientTreeViewNode.GetNode property to access a node’s child with the specified index.

Note

This method returns an incorrect value if the EnableClientSideAPI property is set to false (default). Set this property to true to enable access to a control’s client-side object.

Example

The code below lists checked nodes and shows them in a label on the client side.

<script type="text/javascript">
    function OnCheckedChanged(s, e) {
        label.SetText("Checked nodes:");
        ListCheckedNodes(s);
    }

    function ListCheckedNodes(parent){    
        for (var i=0; i < parent.GetNodeCount(); i++){
            if (parent.GetNode(i).GetChecked()){
               label.SetText(label.GetText() + " " + parent.GetNode(i).GetText());    
            }
            if (parent.GetNode(i).GetNodeCount() != 0){
               ListCheckedNodes(parent.GetNode(i));
            }
        }
    }
</script>
<dx:ASPxTreeView ID="ASPxTreeView1" runat="server" AllowCheckNodes="True" ClientInstanceName="treeview" DataSourceID="XmlDataSource1">
    <ClientSideEvents CheckedChanged="OnCheckedChanged" />
</dx:ASPxTreeView>
<br />
<dx:ASPxLabel ID="ASPxLabel1" runat="server" ClientInstanceName="label" Text="Checked nodes:">
</dx:ASPxLabel>
<asp:XmlDataSource ID="XmlDataSource1" runat="server" DataFile="~/App_Data/MenuTabbedMenu.xml" XPath="/mainmenu/item"></asp:XmlDataSource>
See Also