LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

expand unexpand parent nodes in tree

Hello
I have a tree of some 3400 entries. It represents the conditions and treatments in a neonatal intensive care unit. The entries are organized as Neonatal > Respiratory > CRS > ??? down to six levels. Each entry has only one parent and parents may have many children some of which may themselves be parents. I would like to un-expand (contract?) the child nodes that are not parents. I can't see the way to do this? Are trees really a good solution to show a large structure like this?

From the .jpg attached I'd like the child nodes contracted and just to see Hearing Loss and Nasal Polyp, the two parent nodes.

Yours Sincerely
John
0 Kudos
Message 1 of 2
(3,028 Views)
The best time to enforce this would be to do it while you build up the tree. Take a look at the attached VI.

Basically whenever you add an element you need to do 2 things. Call the Open/Close Item method and close your the new tag. Then call Ensure Visible on the parent.

The reasoning behind this is that if an item is closed, and you add a child it will not open, therefore when one of your children becomes a parent the child will not show up. However as you get deeper you need to ensure that the parent shows up, even if it is a child.

So in my example I create parents and some children, which are nicely closed. I then add some children to 1 child. Notice the newest child is hidden but the parent shows up. I also wanted to point out that somet
imes children may show up like in this example where a child and parent are the same level.

Another option would be to store in an array all the children tags, and you can call Close on all them in a loop.
Message 2 of 2
(3,028 Views)