Specify location for nodes loaded through WebService

3 posts, 1 answers
  1. John
    John avatar
    41 posts
    Member since:
    Nov 2007

    Posted 08 Oct 2009 Link to this post

    Hi

    I have a RadTreeView that initially loads some nodes (hierarchical) and then some of the nodes when expanded load more nodes through web service. What happens is that the nodes loaded through the WebService go below the nodes that were already loaded under that node, like this

    - PreloadedNode
    --- PreloadedNode
    --- PreloadedNode
    --- WebServiceNode
    --- WebServiceNode

    What I want is to display the WebService nodes above the Preloaded nodes like so

    - PreloadedNode1
    --- WebServiceNode
    --- WebServiceNode
    --- PreloadedNode
    --- PreloadedNode

    Is this possible?

    Thanks a lot in advance! :)
  2. Answer
    Yana
    Admin
    Yana avatar
    5015 posts

    Posted 12 Oct 2009 Link to this post

    Hello Bidan,

    The only way to achieve this is to switch the positions of the nodes after they're loaded in OnClientNodePopulated event handler like this:

    <script type="text/javascript">
            function nodePopulated(sender, args) {
                var node = args.get_node();
                for (var i = 2; i < node.get_nodes().get_count(); i++) {
                    var subnode = node.get_nodes().getNode(i);
                    node.get_nodes().remove(subnode);
                    node.get_nodes().insert(0, subnode);
                }
            }
    </script>


    Best wishes,
    Yana
    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.
  3. John
    John avatar
    41 posts
    Member since:
    Nov 2007

    Posted 12 Oct 2009 Link to this post

    Thanks a lot Yana

    It works fine, although it's a bit inefficient (add nodes in the DOM, remove them, then add them again)

    Regards
Back to Top