jsTreeR icon indicating copy to clipboard operation
jsTreeR copied to clipboard

Cannot select node with child

Open RightChain opened this issue 2 years ago • 5 comments

I want to be able to select just one node that may or may not have children and only return that node.

Two issues:

  1. With "multiple" set to FALSE, multiple children will be returned when selecting a node.
  2. When I want to select a node but not its children, all of the children are selected and returned rather than the node.

Is there a way to determine the actual node that was selected when the selected node has children?

RightChain avatar Jun 17 '22 21:06 RightChain

Hello,

Please next time use StackOverflow for questions like this.

I'm not sure to understand your question. you want to select a parent node without selecting its children?

stla avatar Jun 18 '22 09:06 stla

Basically I want to select a directory from a file tree. If it has children, then there is no guaranteed way to select only the directory due to how the selection propagates.

RightChain avatar Jun 30 '22 15:06 RightChain

Ok. Indeed, the selection always "cascades" to the children nodes. But you can attach some data to the nodes, e.g. type="folder" and type="file", and then filter the selection. But yes, the children will be selected, visually speaking.

stla avatar Jun 30 '22 15:06 stla

Right, but I want to be able to select a "folder" that contains another "folder." Is there a way to change how the selection "cascades"?

RightChain avatar Jun 30 '22 16:06 RightChain

No, but that's not a problem. Each folder will have the "attribute" type="folder", and you filter all nodes which have this attribute.

stla avatar Jun 30 '22 17:06 stla