Skip to main content

ASPxClientTreeViewNode.GetNode(index) Method

Returns the current node’s immediate child node specified by its index.

Declaration

GetNode(
    index: number
): ASPxClientTreeViewNode

Parameters

Name Type Description
index number

The index of the node to be retrieved.

Returns

Type Description
ASPxClientTreeViewNode

An ASPxClientTreeViewNode object representing the node located at the specified index within the current node collection.

Remarks

The ASPxTreeView’s client-side functionality enables you to access and manipulate nodes on the client side. Use the GetNode method to get the client-side node object at the specified index in the list of the current node’s immediate child nodes. The nodes of the immediate child collection are maintained by the node’s TreeViewNode.Nodes collection. This method can be used together with the ASPxClientTreeView.GetNodeCount method, when iterating through the list of the immediate child nodes.

Note that the index parameter is zero-based and its upper available value is specified by the ASPxClientTreeViewNode.GetNodeCount value decremented by one. If you pass an invalid index via the parameter, the method returns null.

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