Expand Tree programatically

7 posts, 0 answers
  1. Chris
    Chris avatar
    11 posts
    Member since:
    Dec 2004

    Posted 27 Nov 2008 Link to this post

    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
  2. Veselin Vasilev
    Admin
    Veselin Vasilev avatar
    2992 posts

    Posted 27 Nov 2008 Link to this post

    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.
  3. UI for ASP.NET Ajax is Ready for VS 2017
  4. Mallverkstan
    Mallverkstan avatar
    20 posts
    Member since:
    May 2007

    Posted 02 Dec 2008 Link to this post

    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

  5. Veselin Vasilev
    Admin
    Veselin Vasilev avatar
    2992 posts

    Posted 05 Dec 2008 Link to this post

    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.
  6. Mallverkstan
    Mallverkstan avatar
    20 posts
    Member since:
    May 2007

    Posted 08 Dec 2008 Link to this post

    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
  7. Veselin Vasilev
    Admin
    Veselin Vasilev avatar
    2992 posts

    Posted 08 Dec 2008 Link to this post

    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.
  8. Mallverkstan
    Mallverkstan avatar
    20 posts
    Member since:
    May 2007

    Posted 10 Dec 2008 Link to this post

    Thanks for the suggestion to use a ClientSide expandmode. I hadn't thought about that, but I tried it and it works.

    Regards,
    Fredrik
Back to Top
UI for ASP.NET Ajax is Ready for VS 2017