q-tree - issues with ticked nodes
-
I have a q-tree question, given this codepen:
https://codepen.io/jeffbcole/pen/bGNXVNa?editable=true&editors=101
I need ‘leaf’ tick strategy behavior, with the following…
(0) When the user selects the node “0” with no other nodes selected I need the “ticked” array to contain all node id’s, including 0, 1, 2, 3. It currently only contains the id’s of the innermost children [‘1.1’, ‘1.2’, ‘2.1’, ‘2.2’, ‘3.1’, ‘3.2’]
(1) When the user selects the node “2” (with no other nodes selected) I need the “ticked” array to contain [‘0’, ‘2’, ‘2.1’, ‘2.2’] - i.e. any node in the hierarchy above the selected node. As written the “ticked” array only contains [‘2.1’, ‘2.2’].
(2) When the user selects the node “2.1” (with no other nodes selected) I need the “ticked” array to contain [‘0’, ‘2’, ‘2.1’] - i.e. any node in the hierarchy above the selected node. As written the “ticked” array only contains [‘2.1’].
(3) I’d like the tree to be fully expanded with no ability to expand/collapse any node.
I’m using q-tree in my application as a way to set hierarchal permissions.
Any help on the above is greatly appreciated.
Jeff.
-
(3): Disabling expansion could be achieved with the following:
<q-tree ... :expanded.sync="expanded" >
computed: { expanded: { get() { // return all keys }, set(value) { // do noting } } }
For the other points: It sounds like you are describing the “strict” tick-strategy with the following adjustment:
- When a node it ticked, tick all parent nodes up to the root node
You could implement that in a watcher on theticked
property
- When a node it ticked, tick all parent nodes up to the root node