EasyUI Forum

General Category => EasyUI for jQuery => Topic started by: jlivio on June 26, 2015, 02:33:45 AM



Title: UI Tree change behavior
Post by: jlivio on June 26, 2015, 02:33:45 AM
Hi!

In a structure like this

1
--- 1.1
--- 1.2

When I click (1) is it possible to reverse the process? instead of check 1.1 and 1.2 automatically, I want to unchecked, but when I check (1.1, 1.2) the behavior is the same (1) become indeterminate.

Thanks
Joao 


Title: Re: UI Tree change behavior
Post by: stworthy on June 26, 2015, 06:19:16 AM
When check a node, the 'onCheck' event fires. You can call 'uncheck' method to un-check all the child nodes when a parent node is checked.
Code:
$('#tt').tree({
cascadeCheck: true,
onCheck: function(node, checked){
var opts = $(this).tree('options');
var onCheck = opts.onCheck;
opts.onCheck = function(){};
var data = $(this).tree('getData',node.target);
if (data.children){
for(var i=0; i<data.children.length; i++){
$(this).tree('uncheck', data.children[i].target);
}
}
opts.onCheck = onCheck;
}
})


Title: Re: UI Tree change behavior
Post by: jlivio on July 03, 2015, 04:10:11 AM
Hi!

I explained badly on this

behavior is the same (1) become indeterminate.

Ment to say

behavior is the same (1) become checked.

Thanks for helping. When include your code, I'm not able to check (1), only (1.1) and (1.2).

Can you give me a clue?

Thanks
Joao