treejs icon indicating copy to clipboard operation
treejs copied to clipboard

Some nodes are not checked

Open Praetorian11 opened this issue 3 years ago • 2 comments

Hello, Strange problems, please see code bellow

`

<pre><code></title> <script src="dist/tree.min.js"></script> </code></pre>
`

All nodes are checked by initial data, but 2 nodes "Book Issue" and "Book Return" are not checked, very strange.

obrazek Can you check it, please? Thank you.

Praetorian11 avatar Feb 21 '22 10:02 Praetorian11

That is the logic behind it:

Every "checked: true" is handled like a click on the node.

If you start with a completely unchecked treeview and click on Library, all subnotes are checked. If you also click "Book Issue", it becomes unchecked again.

Same with "Book Fine", but it is checked again when you click on "Fee Payment".

Solution: Set "checked: true" only for the node that should really be selected (e.g. "Fee Payment" and not "Book Fine" or "Library").

But I would guess that this is a bug and not intended...

Wonko52 avatar Mar 09 '22 09:03 Wonko52

only set checked=true on nodes that do not have children on their own because their checked / half checked / not checked status is inherited by the sum of checked children

Inside the Tree.parseTreeData one may add

- if (node.checked ) values.push(node.id);
+ if (node.checked && (!node.children || node.children.length === 0) ) values.push(node.id);

THenkeDE avatar Oct 17 '23 08:10 THenkeDE