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

Get All TreeList Items

2 Answers 159 Views
TreeList
This is a migrated thread and some comments may be shown as answers.
William
Top achievements
Rank 1
William asked on 16 Dec 2011, 05:38 PM
I would like to iterate through all of my TreeList items, but I can only seem to return the parent items and not the children. 

Here is the code I have so far:

foreach (TreeListDataItem i in notificationsTree.Items)
{
    string test21 = i.Cells[3].Text.ToString();
}

2 Answers, 1 is accepted

Sort by
0
Princy
Top achievements
Rank 2
answered on 19 Dec 2011, 06:13 AM
Hello,

Take a look into the following code snippet.
Accessing Cells and Items

Thanks,
Princy.
0
Abhishek
Top achievements
Rank 2
answered on 18 Jan 2012, 11:49 AM
Hello William,

I have posted one example for your issue, In which i am iterating through the expanded nodes so that you can get the child node item text. I don't know it's correct way or not.
Note: To iterate through the child nodes parent node should be expanded. I wrote for node expansion and commented that code please have look.
foreach (TreeListDataItem item in rtlBusinessUnit.Items)
           {
               if (item.CanExpand)
               {
                   if (item.Expanded)
                   {
                       if (item.ChildItems.Count > 0)
                       {
                           foreach (TreeListDataItem Child in item.ChildItems)
                           {
                               string ItemName = Child["Name"].Text;
                           }
                       }
                   }
                   //else
                   //{
                   //    item.Expanded = true;
                   //    if (item.ChildItems.Count > 0)
                   //    {
                   //        foreach (TreeListDataItem Child in item.ChildItems)
                   //        {
                   //            string ItemName = Child["Name"].Text;
                   //        }
                   //    }
                   //    //item.Expanded = false;
                   //}
               }             


Thanks,
Abhishek K
Tags
TreeList
Asked by
William
Top achievements
Rank 1
Answers by
Princy
Top achievements
Rank 2
Abhishek
Top achievements
Rank 2
Share this question
or