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

Expand all

3 Answers 47 Views
TreeList
This is a migrated thread and some comments may be shown as answers.
HelloWorld
Top achievements
Rank 1
HelloWorld asked on 13 Jun 2013, 11:45 AM
Hello,

This code below is from one of demo code from

TreeList - Forum with External Edit Form

ExpandItemToLevel() is using 50 which seems a random number!!
is there a way to find how many the level a item has to expand??

Thanks!!
case
 RadTreeList.ExpandCollapseCommandName:
//if the command is fired for a root item by the LinkButton inside it, all child items should be expanded
if ((e.Item as TreeListDataItem).HierarchyIndex.NestedLevel == 0 && e.CommandArgument.ToString() == "ExpandAll")
        {
            e.Canceled = true;
            if (!(e.Item as TreeListDataItem).Expanded)
             {
              ForumBoard.ExpandItemToLevel((e.Item as TreeListDataItem), 50);
  // 50 is a random number as Level to exand all I assume
  // is there a way to find how many level it has to expand??
               }
               else
                {
                 ForumBoard.CollapseAllItems();
                 }
           }
            EditFormPanel.Visible = false;
            break

3 Answers, 1 is accepted

Sort by
0
Eyup
Telerik team
answered on 18 Jun 2013, 05:24 AM
Hi Charlie,

Have you tried the ExpandAllItems method?
http://www.telerik.com/help/aspnet-ajax/treelist-server-side-basics.html
( Section Server-side Methods)

Hope this works for you. Looking forward to your reply.

Regards,
Eyup
Telerik
If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to the blog feed now.
0
HelloWorld
Top achievements
Rank 1
answered on 18 Jun 2013, 06:43 PM
I tried the ExpandAllItems method.
the method expands every rows.
I want to expand a particular item the user clicks to show every child items under the item.

Thanks.
0
Eyup
Telerik team
answered on 24 Jun 2013, 10:26 AM
Hi Charlie,

I am afraid there is no way to tell the max nested level depth of the item without expanding its child items. Therefore, you will need to use the ExpandItemToLevel approach with a big int number which would be practically impossible to reach. The method recursively traverses and toggles the expanded state of the child items and it will stop when there are no more items to expand.

Hope the clarification was helpful.

Regards,
Eyup
Telerik
If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to the blog feed now.
Tags
TreeList
Asked by
HelloWorld
Top achievements
Rank 1
Answers by
Eyup
Telerik team
HelloWorld
Top achievements
Rank 1
Share this question
or