Start Building Professional
Web Apps Today


 
Categories Question details Back To List
Question  posted on Mar 07, 2007 11:04
open dhtmlx forum
The problem that I'm running into, is that on the tree, checking the root selects everything underneath,...

The problem that I'm running into, is that on the tree, checking the root selects everything underneath, and checking the parent selects everything under it. (as it should) However, no code exists to handle these two instances. There is, however, code to handle the child nodes.

My question is:

How can I disable the root and parent nodes from selecting the child nodes, but allowing the child node (when selected) to select the parent node?
Answer posted on Mar 07, 2007 11:05

The tree doesn't support such behaviour, but you can use one of next two workarounds:

 a) Define top level checkboxes as disabled (disableCheckbox method, or "disabled" attribute in XML)

 b) Create custom onCheck handler

tree.enableThreeStateCheckboxes(false);

tree.setOnCheckHandler(function(id,state){

                if(!tree.hasChildren(id)){

                               tree.enableThreeStateCheckboxes(true);

                               var item=tree._globalIdStorageFind(tree.getParentId(id));

                               tree._correctCheckStates(item,state);

                               tree.enableThreeStateCheckboxes(false);

                               }

                else tree.setCheck(id,!state);

});

such code allows checking only of "leaf" items in tree.
Answer posted by sematik (Support) on Nov 30, 2014 06:56

Not much can be said in addition to the reply above, but you also can check gent chart and datagrid edit and find out what we have probably missed in our explanation.