Hello,
If you would prefer to attach the logic on an appropriate event, I suggest handling nodeCheckstateChanging. It is a cancellable event so you could run the checks if this is a root lv or a particular root lv node checked and return false in case you want to disable the user from interacting with it.
ui.node.path – returns string showing the node path. Could be used to locate specific node or if it is specific node lv
For example in case you have tree parent and nodes and each has 2 child nodes. If you want to check for a particular root node, inspect the returned root value. It will be “zero based”.
Clicking the first root node will return “0”
Clicking the second one will return “1”
Clicking the second child node of the second root node will return “1_1”
An easy way to find if it is a root lv node you could check the path length (ui.node.path.length) and if it is 1, obviously it is a root node. You could use this check to apply logic to all root nodes.
Similar approach will be to access the checked/unchecked node data and see if this is the one you want to conditionally disable. For example In case the Root Node you want to disable has a RegionName == “North America”, it is possible to use the following condition and check:
if ((ui.node.data.RegionName !== undefined) && (ui.node.data.RegionName === “North America”)) {return false;}
Please notice, this will still allow you to check/uncheck the child nodes for the North America root node and the state of the root node as well as the css will be applied correctly. In a similar manner it is possible to disable the child nodes as well.
I am attaching code sample illustrating this for reference.
igTree_Checkboxes_ConditionalyChange