The requested page is not available for the requested platform. You are viewing the content for Default platform.

ASPxClientTreeView.GetNode(index) Method

Returns a node specified by its index within the ASPxTreeView's node collection.

Declaration

GetNode(index: number): ASPxClientTreeViewNode

Parameters

Name Type Description
index number

An integer value specifying the zero-based index of the node to be retrieved.

Returns

Type Description
ASPxClientTreeViewNode

An ASPxClientTreeViewNode object, representing the node located at the specified index within the ASPxTreeView's node collection.

Remarks

The ASPxTreeView's client-side functionality enables you to access and manipulate nodes on the client. Use the GetNode method to get the client-side node object at the specified index within the ASPxTreeView's node collection using array notation. This method can be used together with the ASPxClientTreeView.GetNodeCount method when iterating through the list of a node collection.

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

In order to access nodes further down the ASPxTreeView, you can use the ASPxClientTreeViewNode.GetNode property of a child node.

Examples

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