EasyUI Forum
April 29, 2024, 01:16:29 AM *
Welcome, Guest. Please login or register.

Login with username, password and session length
News:
 
   Home   Help Search Login Register  
Pages: [1]
  Print  
Author Topic: easyui tree data output  (Read 8369 times)
David
Newbie
*
Posts: 1


View Profile
« on: October 10, 2012, 06:42:12 PM »

Hi all,

I am using tree http://www.jeasyui.com/documentation/tree.php and I can construct the tree from db data and it looks good.

In the demo example, I can see a function calling children:-
function getChildren(){
        var node = $('#tt1').tree('getSelected');
        if (node){
            var children = $('#tt1').tree('getChildren', node.target);
        } else {
            var children = $('#tt1').tree('getChildren');
        }
        var s = '';
        for(var i=0; i<children.length; i++){
            s += children.text + ',';
        }
        alert(s);
    }

while performing further drag and drop, I would like to get the new parentID for the moved file so that I can do some db updating, moreover, if I wish to trigger the event by 'onmouse up' rather than 'getSelected', what shall I do? Thanks!
Logged
stworthy
Administrator
Hero Member
*****
Posts: 3581


View Profile Email
« Reply #1 on: October 11, 2012, 02:39:06 AM »

When drop a node on a specify node, the 'onDrop' event is triggered, in which you can get the target node to be dropped and the source node.
Code:
$('#tt').tree({
dnd: true,
onDrop: function(target,source,point){
var node = $(this).tree('getNode', target);
alert(node.id); // the new parent node id
}
});
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!