dhtmlxTree operates the advanced chechbox system. Besides usual two-state checkboxes (checked item, unchecked item), there is the possibility to use three-state checkboxes with “partly-checked” value.
Method enableCheckboxes() does the very thing:
<script> tree.enableCheckBoxes(mode, hidden); </script>
The parameters here are as follows:
In case of creating checkboxes with the help of the above mentioned method, they will possess the usual checkbox states:
The following method is responsible for enabling three-state checkboxes:
<script> tree.enableThreeStateCheckboxes(true|false); </script>
The following states are available for three-state checkboxes:
The third state takes place when the item has several child nodes among which there are checked and unchecked ones.
It should be noted that in case when three-state checkboxes are enabled, a click on a parent unchecked checkbox will result in checking it together with all its child items, and vice versa.
A checkbox of a certain item can be disabled. The parameters that are to be specified:
<script> tree.disableCheckbox(itemId,mode); </script>
The user can set checkboxes for some specific items only. This can be done in the following way:
<script> tree.enableCheckBoxes(true, true); ... tree.showItemCheckbox(id, mode); </script>
The parameters here are:
Method enableSmartCheckboxes() enables three-state checkboxes logic. By default it is set to false:
<script> tree.enableSmartCheckboxes(true|false); // false by default </script>
Any checkbox in the tree can be easily checked|unchecked from script with the help of the following method:
<script> tree.setCheck(id, mode); </script>
The parameters are as follows:
It should be noted that according to three-state checkboxes' logic, if a parent item was checked with the help of setCheck() method, all its child items will become checked as well.
Along with checking a tree item, a tree branch can also be easily checked/unchecked from script in the following way:
<script> tree.setSubChecked(id, state); </script>
The parameters are as follows:
State of the specified item's checkbox can be got in the following way:
<script> var checkState = tree.isItemChecked(itemId); </script>