Check documentation for the latest version 6.0 of dhtmlxSuite Manipulating Checkboxes DHTMLX Docs

Manipulating Checkboxes

You can specify checkboxes for TreeView items and easily manipulate them by using the TreeView API.

Enable checkboxes

// enable on init stage
var myTreeView = new dhtmlXTreeView({
    checkboxes: true
});
 
// enable checkboxes from script
myTreeView.enableCheckboxes(true);
 
// disable from script
myTreeView.enableCheckboxes(false);

Working with checkboxes

1) Enable/disable checkbox for a specific item

The disabled state means that the checkbox is visible and can be manipulated from script. However, you can't change its state through mouse clicks.

// to enable
myTreeView.enableCheckbox(id);
 
// to disable
myTreeView.disableCheckbox(id);
 
// check state
var isEnabled = myTreeView.isCheckboxEnabled(id); // return true/false

Related sample:  Checkboxes enable / disable

2) Check/uncheck checkbox

// to check
myTreeView.checkItem(id);
 
// to uncheck
myTreeView.uncheckItem(id);
 
// is checked?
var isChecked = myTreeView.isItemChecked(); // return true/false

Related sample:  Checkboxes check / uncheck

3) Show/hide checkbox

// to show
myTreeView.showCheckbox(id);
 
// to hide
myTreeView.hideCheckbox(id);
 
// check state
var isVisible = myTreeView.isCheckboxVisible(id); // return true/false

Related sample:  Checkboxes show / hide

Back to top