This is a migrated thread and some comments may be shown as answers.

Child node count in root

3 Answers 90 Views
TreeView
This is a migrated thread and some comments may be shown as answers.
Herman
Top achievements
Rank 1
Herman asked on 01 Jul 2011, 05:20 AM
Please help i use treeview and want to see the node count in the root ex
I want to see this before expanding
Catalogue (3)
Items (2)
Services (4)
---------------------------------------------------------------------------------------------------------------------------------------------
Tree look like this

Catalogue
        Catalogue one
                Catalogue two
                        Catalogue three
Items    
      Item one
            Item Twee
Services 
    Services one
            Services two
                    Service three
                            Service four

3 Answers, 1 is accepted

Sort by
0
Shinu
Top achievements
Rank 2
answered on 01 Jul 2011, 07:03 AM
Hello Herman,

Try the following code snippet in page load to achieve your requirement.
C#:
protected void Page_Load(object sender, EventArgs e)
    
        if (!Page.IsPostBack)
        {
            foreach (RadTreeNode node in RadTreeView3.GetAllNodes())
            {
                if (node.Nodes.Count > 0)
                    node.Text = node.Text + " (" + node.Nodes.Count.ToString() + ")";
            }
        }

Thanks,
Shinu.
0
Herman
Top achievements
Rank 1
answered on 01 Jul 2011, 07:08 AM
Thanks for replay but the create the following

Catalogue (1)
    Catalogue one (1)
        Catalogue two (1)
            Catalogue three
I want

Catalogue (3)
    Catalogue one  
        Catalogue two 
            Catalogue three
0
Shinu
Top achievements
Rank 2
answered on 01 Jul 2011, 12:51 PM
Hello Herman,

You can achieve this by checking the node level. Here is the modified code.
C#:
if (!Page.IsPostBack)
{
   foreach (RadTreeNode node in RadTreeView1.GetAllNodes())
   {
     if (node.Nodes.Count > 0 && node.Level==0)
     node.Text = node.Text + " (" + node.Nodes.Count.ToString() + ")";
   }
 }

Thanks,
Shinu.
Tags
TreeView
Asked by
Herman
Top achievements
Rank 1
Answers by
Shinu
Top achievements
Rank 2
Herman
Top achievements
Rank 1
Share this question
or