Please refer to the code below:
$('#tt').tree({
checkbox: false,
formatter:function(node){
var s = '<span style="display:inline-block;width:16px;height:16px" class="tree-flag tree-checkbox'+(node.flag||0)+'"> </span>';
return s + node.text;
}
}).bind('click', function(e){
var flag = $(e.target).closest('span.tree-flag');
if (flag.length){
var t = flag.closest('div.tree-node');
var f = 0;
if (flag.hasClass('tree-checkbox0')){
f = 1;
} else if (flag.hasClass('tree-checkbox1')){
f = 2;
} else {
f = 0;
}
$('#tt').tree('update',{
target: t[0],
flag: f
})
}
})
Use a 'flag' property to represent the current node state(read-only,read-write,no access). Use the 'formatter' function to display the node's checkbox regarding its flag. Click a un-checked node, the node will be checked. Click it again, it will be indeterminate. etc.