ASPxClientTreeView.GetNodeCount Method

Returns the number of nodes at the ASPxTreeView's zero level.


GetNodeCount(): number


Type Description

An integer value specifying the number of the root node child nodes.


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


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

View Example

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

    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){
<dx:ASPxTreeView ID="ASPxTreeView1" runat="server" AllowCheckNodes="True" ClientInstanceName="treeview" DataSourceID="XmlDataSource1">
    <ClientSideEvents CheckedChanged="OnCheckedChanged" />
<br />
<dx:ASPxLabel ID="ASPxLabel1" runat="server" ClientInstanceName="label" Text="Checked nodes:">
<asp:XmlDataSource ID="XmlDataSource1" runat="server" DataFile="~/App_Data/MenuTabbedMenu.xml" XPath="/mainmenu/item"></asp:XmlDataSource>
See Also