treejs
treejs copied to clipboard
Some nodes are not checked
Hello, Strange problems, please see code bellow
`
</title>
<script src="dist/tree.min.js"></script>
All nodes are checked by initial data, but 2 nodes "Book Issue" and "Book Return" are not checked, very strange.
Can you check it, please? Thank you.
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...
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);