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

Re-expanding a node doubles (multipies) children

2 Answers 10 Views
TreeView
This is a migrated thread and some comments may be shown as answers.
Claude
Top achievements
Rank 1
Claude asked on 07 Oct 2014, 12:42 PM
Hi support team,

Telerik TreeView is awesome, all my requirements are met. Great job!
But here I am stuck:

- I have a tree and the user can select multiple nodes.
- Initially, some nodes are expanded, so that all selected nodes are displayed. I do this with a datasource and with the OnNodeDataBound. 
- All nodes can be expanded with TreeNodeExpandMode.WebService

All works fine but when I collapse a initially loaded node, and then expand it again, the number of child nodes doubles, each child node is contained twice. When I do this again, it is still contained twice (not tree times).

How does the control do the "identity". Is is not the RadTreeNode.Value? 
One workaround is the set the ExpandMode of RadTreeNode to Server to all nodes that are initially expanded. But then the user can not collapse it (nothing happens when the user clicks -).  Best regards, a good customer 








2 Answers, 1 is accepted

Sort by
0
Accepted
Nencho
Telerik team
answered on 10 Oct 2014, 10:20 AM
Hello Claude,

Indeed the duplication behavior occurs with such an approach. In order to overcome it, I would suggest you to handle the OnClientNodePopulating client-side event of the RadTreeView, which is triggered just before the request to the WebService. At this stage, you could verify the current count of child nodes and clear them if are any. Please consider the following implementation :

<script type="text/javascript">
           function OnClientNodePopulating(sender, args) {
               if (args.get_node().get_nodes().get_count() > 0)
                   args.get_node().get_nodes().clear();
           }
       </script>

Regards,
Nencho
Telerik
 

Check out the Telerik Platform - the only platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native mobile apps.

 
0
Claude
Top achievements
Rank 1
answered on 13 Oct 2014, 11:40 AM
Thanks a lot, that helped.
Tags
TreeView
Asked by
Claude
Top achievements
Rank 1
Answers by
Nencho
Telerik team
Claude
Top achievements
Rank 1
Share this question
or