EasyUI Forum

General Category => EasyUI for jQuery => Topic started by: xavirrr on September 19, 2012, 12:51:44 AM



Title: Tree: Getting new parent on drop
Post by: xavirrr on September 19, 2012, 12:51:44 AM
Hi,

I'm trying to get the id of the new parent node of the element that has been dropped. The further thing I've got is this:

Code:
onDrop: function(target, source, point) {
    $(this).tree('getNode',target).id;
}

Which gets the ID of the drop target, but not always is the parent, It may be a sibling when it is dropped next to it.

Thanks,
xavi


Title: Re: Tree: Getting new parent on drop
Post by: xavirrr on September 21, 2012, 02:18:18 AM
Nobody knows how to?  :'(


Title: Re: Tree: Getting new parent on drop
Post by: xavirrr on September 25, 2012, 05:39:26 AM
okay, I got it:

Code:
            onDrop: function(target,source,point){
                var idParentCategory;
                if(point == "append") {
                    idParentCategory = $(this).tree('getNode',target).id
                } else {
                    if($(this).tree('getParent',target) === null) {
                        // is root
                        idParentCategory = 0;
                    } else {
                        idParentCategory = $(this).tree('getParent',target).id
                    }
                }
                console.log(idParentCategory)
}

Thank u all ;)