Re-expanding a node doubles (multipies) children

3 posts, 1 answers
  1. Claude
    Claude avatar
    2 posts
    Member since:
    Oct 2014

    Posted 07 Oct 2014 Link to this post

    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. Answer
    Nencho
    Admin
    Nencho avatar
    1457 posts

    Posted 10 Oct 2014 Link to this post

    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.

     
  3. UI for ASP.NET Ajax is Ready for VS 2017
  4. Claude
    Claude avatar
    2 posts
    Member since:
    Oct 2014

    Posted 13 Oct 2014 in reply to Nencho Link to this post

    Thanks a lot, that helped.
Back to Top