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

Remove Duplicate Child Nodes in RadTreeView?

3 Answers 106 Views
Menu
This is a migrated thread and some comments may be shown as answers.
Daica
Top achievements
Rank 1
Daica asked on 21 Mar 2019, 09:20 PM

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

3 Answers, 1 is accepted

Sort by
0
Daica
Top achievements
Rank 1
answered on 21 Mar 2019, 09:26 PM

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
0
Accepted
Dess | Tech Support Engineer, Principal
Telerik team
answered on 26 Mar 2019, 09:22 AM
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.
0
Daica
Top achievements
Rank 1
answered on 26 Mar 2019, 02:38 PM

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. 

Tags
Menu
Asked by
Daica
Top achievements
Rank 1
Answers by
Daica
Top achievements
Rank 1
Dess | Tech Support Engineer, Principal
Telerik team
Share this question
or