EasyUI Forum

General Category => EasyUI for jQuery => Topic started by: Stefan B. on January 24, 2014, 06:56:18 AM



Title: unselect a selected tree node
Post by: Stefan B. on January 24, 2014, 06:56:18 AM
Can one help me with my question?

How can I unselect a selected tree node per code?
I found am method "select" but no a method "unselect".


Title: Re: unselect a selected tree node
Post by: stworthy on January 25, 2014, 01:12:58 AM
It is easy to extend the 'unselect' method.
Code:
<script>
$.extend($.fn.tree.methods,{
unselect:function(jq,target){
return jq.each(function(){
var opts = $(this).tree('options');
$(target).removeClass('tree-node-selected');
if (opts.onUnselect){
opts.onUnselect.call(this, $(this).tree('getNode',target));
}
});
}
});
</script>

The code below shows how to unselect the selected node.
Code:
var t = $('#tt');  // the tree object
var node = t.tree('getSelected');
t.tree('unselect', node.target);


Title: Re: unselect a selected tree node
Post by: Stefan B. on January 27, 2014, 02:03:11 AM
THX for this example, this is a very good solution. I try it and it works fine. :)