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

Expand Tree programatically

6 Answers 185 Views
TreeView
This is a migrated thread and some comments may be shown as answers.
Chris
Top achievements
Rank 1
Chris asked on 27 Nov 2008, 08:40 AM
I have build an example similar to:

/radcontrols_aspnetajax/TreeView/Examples/Programming/LoadOnDemandSql/DefaultVB.aspx

I would like open subtrees programatically (vb.net function, server side), instead of manually clicking the nodes.
How i can make "load on demand" with server side code? I dont find a method to do this.

thanks

chris

6 Answers, 1 is accepted

Sort by
0
Veselin Vasilev
Telerik team
answered on 27 Nov 2008, 12:49 PM
Hello Christian Luerzer,

Please check the Troubleshooting > Expanding Nodes article.

I hope this helps.

Greetings,
Veselin Vasilev
the Telerik team

Check out Telerik Trainer, the state of the art learning tool for Telerik products.
0
Mallverkstan
Top achievements
Rank 2
answered on 02 Dec 2008, 11:27 AM
Is it okay if I add to this question or should I start a new?

I also have problem with expanding a node. I am running AJAX RadControl version 2008.2.826.20.

http://www.telerik.com/help/aspnet-ajax/troubleshooting-expanding-nodes.html says that nodes can't be expanded server side if "ExpandMode = ServerSideCallBack". But they can! Just set the Expand property of the node to true.

The page also speaks of the server-side method method "Expand()", but there is no such method on either TreeView nor TreeNode (server-side). What is being referring to here?

My problem:
So I can expand the tree server-side, and the expand-Image is shown alright, but the little "+" doesn't change to a "-". Here is a screenshot: http://filer.mallverkstan.se/filer/radtree_screenshot.jpg. The expanded nodes were all expanded on the server side. Can you help me? I looked everywhere on how to change it.

Also, the help doesn't explain how how to expand nodes with the select() method from server-side when the node has expandmode ServerSideCallBack. I tried to register a javascript function that takes the nodes value and makes a "node = tree.findNodeByValue(value); node.get_parent().expand();" but it didn't change the "+" icon. So, I do have to expand the tree server side in some other way or what can I do?

Thanks,
Fredrik

0
Veselin Vasilev
Telerik team
answered on 05 Dec 2008, 01:07 PM
Hello Mallverkstan,

Setting the Expanded property of a node to True does not expand it if its ExpandMode is set to ServerSideCallBack.

The troubleshooting page referenced an Expand() method, while actually the meaning was the Expanded property. It has been updated.

I am afraid the page with the image does not open.

Here is a sample code in C# which registers a client script on the page, which expands a node which has  ServerSideCallBack expand mode:

string script = @"function pageLoad(){
                var tree = $find('RadTreeView1'); 
                var firstNode = tree.get_nodes().getNode(0);
                setTimeout(function() {firstNode.expand();}, 1)}"
 
ScriptManager.RegisterStartupScript(Page, Page.GetType(), "expandNode", script, true); 

I hope this helps.

All the best,
Veselin Vasilev
the Telerik team

Check out Telerik Trainer, the state of the art learning tool for Telerik products.
0
Mallverkstan
Top achievements
Rank 2
answered on 08 Dec 2008, 10:54 AM
Thank you for your kind help.

Sorry about the image, it was a problem here at the server. It should work now. The address again: http://filer.mallverkstan.se/filer/radtree_screenshot.jpg.

I didn't mention that my workaround for expanding nodes server side was to remove the desired nodes from the tree and add them again with the Expanded property set to true. This was made during a postback. It resulted in the screenshot I provide.

Thank you for the code. I suspected a timer function of some sort could be used. I will test it shortly and get back to you.

Regards,
Fredrik
0
Veselin Vasilev
Telerik team
answered on 08 Dec 2008, 11:55 AM
Hello Mallverkstan,

This would happen only if you have a node with ExpandMode set to ServerSide / ServerSideCallBack / WebService and also that node has a static node as well. This is the expected behavior - the plus sign shows that the user has not yet expanded that node to retrieve its children using the load-on-demand mechanism.

If you plan not to use the load-on-demand scenario - just set the ExpandMode to ClientSide.

Best wishes,
Veselin Vasilev
the Telerik team

Check out Telerik Trainer, the state of the art learning tool for Telerik products.
0
Mallverkstan
Top achievements
Rank 2
answered on 10 Dec 2008, 03:10 PM
Thanks for the suggestion to use a ClientSide expandmode. I hadn't thought about that, but I tried it and it works.

Regards,
Fredrik
Tags
TreeView
Asked by
Chris
Top achievements
Rank 1
Answers by
Veselin Vasilev
Telerik team
Mallverkstan
Top achievements
Rank 2
Share this question
or