EasyUI Forum
May 18, 2024, 05:42:34 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: Tree: Getting new parent on drop  (Read 10463 times)
xavirrr
Newbie
*
Posts: 3


View Profile Email
« 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
Logged
xavirrr
Newbie
*
Posts: 3


View Profile Email
« Reply #1 on: September 21, 2012, 02:18:18 AM »

Nobody knows how to?  Cry
Logged
xavirrr
Newbie
*
Posts: 3


View Profile Email
« Reply #2 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 Wink
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!