LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Tree structure function 'move' problem

When I choose a item in tree structure and click 'move down' button, sometimes item will move down one step and sometimes it will move two times? How can I resovle it?

Thank you very much!

0 Kudos
Message 1 of 6
(2,386 Views)

Try to save the VI for a previous LabVIEW version. Not many users have LabVIEW 2019 installed.

Lucian
CLA
0 Kudos
Message 2 of 6
(2,376 Views)

Ok, I have saved to LabVIEW 2015.

0 Kudos
Message 3 of 6
(2,370 Views)

Your problem is in the Moving - you're leaving "New Parent" empty which means whatever you select to move will always become a top-level item, and moving the position to +2 from the existing row number (which doesn't care about indentation/parents).

 

As a result, the behaviour depends on if you select a parent or a child, and conceivably on the number of children (your example only has single number of children per entry, but it could be more complicated I guess).

 

I couldn't find a simple way to do this (although there may be one) - if there isn't you'll need to consider the "Indent Level" property and probably do some parsing based on the actual layout.

 

Some question that might be needed to move forward:

  1. If you select a parent, you want to move it below the next top-level element, correct?
  2. If you select a child element, what should happen?
    1. If it is the only child, should it become a top level item, or the top of the next parent, or not move?
    2. If it is not the only child, should it move down within the same parent item?
    3. If it is the bottom child, should it behave like 2.1 or 2.2?
  3. If you select the bottom item, do you just want nothing to happen?

If you can describe the desired behaviour, it should be possible to achieve, but it might be a little more complicated than the implementation you have right now...

There are "Get Next Item" and "Get Previous Item" methods in the Invoke Node that will probably help. (edit, guess you might not care about get previous, but if you wanted to move up too...)


GCentral
0 Kudos
Message 4 of 6
(2,364 Views)

Hello sir, 

Thank you for your Reply.

I only want to move the top Level(parent). This is a simple demo and I have realized the child Level move.

But I found that if I move the top Level, sometimes item will move one step, but sometimes it will move two steps.

0 Kudos
Message 5 of 6
(2,349 Views)

As a brief reference, the 2015 version is not the same as the 2019 version for other readers (particularly those without 2019 to compare).

 

The possibly key point is that you want to provide a target "New Position" value at the level of the "New Parent" - i.e. root/parent level.

So you want to know the current parent level, and then add two (because it places it above that element, not in that element - probably you already knew this based on your original code).

 

The following works, at least when you only click "Move" for parent level items. If you don't change the items in the tree, you should build the parent/root/top-level list before running the While loop. If you want to do this at each level, you could compare the Indent Levels for equal to the ÄctiveItemTag value you're initially setting.

tree structure (1)_BD.png

 

For children, you can use something like the following to either disallow or find parents (or do something else, etc)

tree structure (1)_BD.png

Traverse until you have no more parents (i.e. it is the top level) then take the input value. If you select a top-level item, this gives an empty string on the first try and so returns the same string that you input.

 

 


GCentral
0 Kudos
Message 6 of 6
(2,323 Views)