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

Specify location for nodes loaded through WebService

2 Answers 47 Views
TreeView
This is a migrated thread and some comments may be shown as answers.
John
Top achievements
Rank 2
John asked on 08 Oct 2009, 10:52 AM
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 Answers, 1 is accepted

Sort by
0
Accepted
Yana
Telerik team
answered on 12 Oct 2009, 10:38 AM
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.
0
John
Top achievements
Rank 2
answered on 12 Oct 2009, 12:49 PM
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
Tags
TreeView
Asked by
John
Top achievements
Rank 2
Answers by
Yana
Telerik team
John
Top achievements
Rank 2
Share this question
or