Remove Duplicate Child Nodes in RadTreeView?

4 posts, 1 answers
  1. Daica
    Daica avatar
    4 posts
    Member since:
    Mar 2019

    Posted 21 Mar Link to this post

    Hello!

    I have the following RadTreeView and I would like to know if it's possible to remove duplicate sub-nodes. Here is how my tree looks like.

    [MAIN NODE 1]        |        (text = Main Node 1)        |        Name = Node1

        [SubNode1]

        [SubNode1]

        [SubNode2]

    [MAIN NODE 2]        |        (text = Main Node 2)        |        Name = Node2
        [SubNode1]
        [SubNode1]
        [SubNode2]

     

    How would I loop through all the main nodes and remove all the duplicate child nodes?

    I created my main node dynamically through code and do not store their .Name property so I cannot just use RadTreeView.Nodes(MainNode)

    Is there something like..

    For Each MainNode In RadTreeView1.MainNodes

    Loop through and delete child nodes if there is a duplicate

  2. Daica
    Daica avatar
    4 posts
    Member since:
    Mar 2019

    Posted 21 Mar Link to this post

    Okay so I was able to loop through the main node by checking the level, however, I wonder how it would affect performance if I have many child nodes (say like 2000+).

    For Each MainNode In RadTreeView1.Nodes.Where(Function(x) x.Level = 0)
    'Loop through each main node and remove any duplicate child nodes
    Next
  3. Answer
    Dess | Tech Support Engineer, Sr.
    Admin
    Dess | Tech Support Engineer, Sr.  avatar
    3282 posts

    Posted 26 Mar Link to this post

    Hello, Daica,  

    RadTreeView stores all root nodes in its Nodes collection. Each RadTreeNode has its own Nodes collection as well. You can iterate it and store the duplicated nodes in a separate collection. After that, remove all nodes in the list from the RadTreeNode.Nodes of the respective parent node. 

    Note that most of the forum threads are reviewed by Telerik representatives and sometimes we address the questions asked by our customers in the forums as well. However, a post in the forum doesn't guarantee you a response from the Telerik support team. Moreover, threads are handled according to license and time of posting, so if it is an urgent problem, we suggest you use a support ticket, which would be handled before a forum thread

    Thank you for your understanding.

    Regards,
    Dess | Tech Support Engineer, Sr.
    Progress Telerik
    Get quickly onboarded and successful with your Telerik and/or Kendo UI products with the Virtual Classroom free technical training, available to all active customers. Learn More.
  4. Daica
    Daica avatar
    4 posts
    Member since:
    Mar 2019

    Posted 26 Mar in reply to Dess | Tech Support Engineer, Sr. Link to this post

    Thanks for the reply and tip!

    For anyone else who wanted to know the solution, I went with a different approach. Instead of removing duplicates, simply check for duplicates before adding the node in. 

Back to Top