EasyUI Forum

General Category => EasyUI for jQuery => Topic started by: Opan Mustopah on November 09, 2014, 10:47:50 PM



Title: onBeforeCheck not work on children tree
Post by: Opan Mustopah on November 09, 2014, 10:47:50 PM
hello,

i have a problem with onBeforeCheck event on tree plugin.
onBeforeCheck will triggered if will physically checked/clicked some node, but when that node had a child node. the onBeforeCheck event not triggered on that child node.

so how to get it work (event onBeforeCheck) on some child node. i need that child node have that event too.
sorry for my poor english.

thanks in advance
Opan


Title: Re: onBeforeCheck not work on children tree
Post by: stworthy on November 10, 2014, 12:25:11 AM
When a node is checked, the 'onBeforeCheck' event only be triggered on this node. You can call 'getChildren' method to get its child nodes including their state in this event.
Code:
$('#tt').tree({
onBeforeCheck:function(node){
var nodes = $(this).tree('getChildren', node.target);
console.log(nodes)
}
})


Title: Re: onBeforeCheck not work on children tree
Post by: Opan Mustopah on November 10, 2014, 12:38:05 AM
thanks stworthy for your answer, but
i've already try that, if the node doesn't have child it will trown an error like this on firebug:
Code:
TypeError: _d7 is undefined

so how to check some node hava a child node or not?
thanks


Title: Re: onBeforeCheck not work on children tree
Post by: stworthy on November 10, 2014, 07:19:25 AM
Please call 'isLeaf' method to determine the specified node is leaf.
Code:
var b = $('#tt').tree('isLeaf', node.target);
if (b){
  console.log('is leaf');
}


Title: Re: onBeforeCheck not work on children tree
Post by: Opan Mustopah on November 10, 2014, 07:07:36 PM
thank you very much stworthy :D