EasyUI Forum

General Category => EasyUI for jQuery => Topic started by: David on October 10, 2012, 06:42:12 PM



Title: easyui tree data output
Post by: David 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!


Title: Re: easyui tree data output
Post by: stworthy 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
}
});