ASPxClientTreeViewNode.GetNodeCount Method

Returns the number of the current node's immediate child nodes.

Declaration

GetNodeCount(): number

Returns

Type Description
number

An integer value specifying the number of the immediate child nodes of the current node.

Remarks

An ASPxTreeView control's client-side functionality allows the immediate child nodes of a particular node to be accessed programmatically. The GetNodeCount method is used to determine the number of the current node's child nodes which are maintained by the TreeViewNode.Nodes collection. This method can be used together with the ASPxClientTreeViewNode.GetNode method, when iterating through the node's list of the immediate child nodes to determine its upper bound.

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