EasyUI Forum
May 20, 2024, 09:02:42 PM *
Welcome, Guest. Please login or register.

Login with username, password and session length
News:
 
   Home   Help Search Login Register  
Pages: [1]
  Print  
Author Topic: unselect a selected tree node  (Read 16193 times)
Stefan B.
Full Member
***
Posts: 152


Software Architekt


View Profile Email
« 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".
Logged
stworthy
Administrator
Hero Member
*****
Posts: 3581


View Profile Email
« Reply #1 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);
Logged
Stefan B.
Full Member
***
Posts: 152


Software Architekt


View Profile Email
« Reply #2 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. Smiley
« Last Edit: January 27, 2014, 02:10:05 AM by Stefan B. » Logged
Pages: [1]
  Print  
 
Jump to:  

Powered by MySQL Powered by PHP Powered by SMF 1.1.18 | SMF © 2013, Simple Machines Valid XHTML 1.0! Valid CSS!