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

Load on Demand - How to return complete trees?

5 Answers 56 Views
TreeView
This is a migrated thread and some comments may be shown as answers.
Christian Sommer
Top achievements
Rank 1
Christian Sommer asked on 28 Sep 2009, 01:08 PM
Hello,

my trees are very dynamic an so it takes a lot of time to generate them node by node,
level by level.

So my Question is, if it is possible to return a complete part of a tree with all its subnotes in one step.
I think I've to return a Treenode-object not a TreenodeData-object. Have'nt I?

Best regards.

5 Answers, 1 is accepted

Sort by
0
Atanas Korchev
Telerik team
answered on 28 Sep 2009, 02:54 PM
Hi Christian Sommer,

Currently it is not possible to load more than one level of nodes using WebService load on demand. You can do so if you use ServerSideCallback load on demand.

Regards,
Albert,
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
0
Brian
Top achievements
Rank 1
answered on 03 Jun 2011, 02:32 PM
I am using the ServerSideCallBack to add more nodes to the expanded node on the NodeExpand event.  In the event I recursively generate child nodes for the node that is expanded. When I add the child nodes to the node that was expanded it only loads the next level. When I click to expand that level is does not have any more nodes loaded even though when I added child nodes in the NodeExpand event there were more than one level of nodes added.  Is there some property I need to set in order for it to load more than one level?

//Code within the NodeExpand event calls recursive method to build child node tree
NewNode = BuildPrerequisiteNode(SubTask);
NewNode.ExpandMode = TreeNodeExpandMode.ServerSideCallBack;
node.Nodes.Add(NewNode);
 
//Recursive method to build the child nodes.
private RadTreeNode BuildPrerequisiteNode(Task p_Prerequisite)
        {
            RadTreeNode node = null;
            try
            {
                node = new RadTreeNode();
                node.Text = string.Format("{0}, {1}", p_Prerequisite.Code, p_Prerequisite.Description);
                node.Value = p_Prerequisite.TaskId.ToString();
                node.ExpandMode = TreeNodeExpandMode.ServerSideCallBack;
 
                if (p_Prerequisite.SubTaskList.Loaded)
                {
                    foreach (Task SubTask1 in p_Prerequisite.SubTaskList)
                    {
                        node.Nodes.Add(BuildPrerequisiteNode(SubTask1));
                    }
                }
                else
                {
                    node.Attributes.Add(KeysCommonTaskMgt.SubTaskLoaded, "False");
                }
            }
                        
            return node;
        }
0
Nikolay Tsenkov
Telerik team
answered on 08 Jun 2011, 06:06 PM
Hello Brian,

The problem is that you set the ExpandMode of a node to ServerSideCallBack, and this way it's automatically considered collapsed. The solution would be, simply, not to specify the expand mode of the newly created and added nodes (this way it will be assumed to be ClientSide).


Regards,
Nikolay Tsenkov
the Telerik team

Browse the vast support resources we have to jump start your development with RadControls for ASP.NET AJAX. See how to integrate our AJAX controls seamlessly in SharePoint 2007/2010 visiting our common SharePoint portal.

0
Brian
Top achievements
Rank 1
answered on 09 Jun 2011, 03:04 PM
Nikolay,

I do not believe you understand what I'm trying to accomplish.  We are trying to configure the amount of nodes a tree loads at any given time.  Lets say the tree has the potential to have 15 level of nodes, and we want to load 5 levels at a time.  When the page first loads we load the first 5 node levels.  Once the user expands the nodes and reaches the 5th level we return to the database and retrieve and build the next 5 levels and attach it to the current bottom node. We continue to do this until there are no more nodes to load.

The issue I am having is that it will load the first 5 levels just fine, and when the user clicks expand on the last level that does not contain any more nodes it returns back to the database and builds the next 5 levels and attaches them the last node that was expanded.  after I add the second 5 levels to the current node I can see that the whole tree is there and correct but when it post back to the page to display only the top node of what was added displays.  There is a plus sign to expand but when you expand there are no nodes present even though I was able to see all the nodes in the code behind before the page posted back to render.

Thanks,
Brian
0
Nikolay Tsenkov
Telerik team
answered on 15 Jun 2011, 10:46 AM
Hi Brian,

The problem is that you load nodes that are with ExpandMode which will trigger server-side callback to run.

"we want to load 5 levels at a time...Once the user expands the nodes and reaches the 5th level we return to the database and retrieve and build the next 5 levels."
 - Here you clearly state that you need to load 5 levels which should be client-side expandable, without the need to go to the server. Well you can do this, by setting all the non-terminal (the others are leafs/the nodes without loaded children, yet) nodes with ExpandMode=ClientSide and all the other nodes with ExpandMode=ServerSideCallback. This way, non-terminal nodes will expand on the client and when the user expands a leaf node the server-side callback will run to gather new nodes.


Regards,
Nikolay Tsenkov
the Telerik team

Browse the vast support resources we have to jump start your development with RadControls for ASP.NET AJAX. See how to integrate our AJAX controls seamlessly in SharePoint 2007/2010 visiting our common SharePoint portal.

Tags
TreeView
Asked by
Christian Sommer
Top achievements
Rank 1
Answers by
Atanas Korchev
Telerik team
Brian
Top achievements
Rank 1
Nikolay Tsenkov
Telerik team
Share this question
or