EasyUI Forum

General Category => EasyUI for jQuery => Topic started by: Szoron on November 20, 2016, 12:32:59 PM



Title: Tree drag&drop (disable children)
Post by: Szoron on November 20, 2016, 12:32:59 PM
Given a list of what component tree is displayed.
I want to sort the contents of the list with drag & drop.
It would be just sort order.
However, I would not like nesting (children)
How can this be disabled?
before
(http://www.kephost.com/images/2016/11/20/Kepernyofoto2016-11-20-20.24.41.jpg)
after
(http://www.kephost.com/images/2016/11/20/Kepernyofoto2016-11-20-20.25.12.jpg)
wrong after
(http://www.kephost.com/images/2016/11/20/Kepernyofoto2016-11-20-20.25.23.jpg)


Title: Re: Tree drag&drop (disable children)
Post by: stworthy on November 21, 2016, 05:34:21 PM
Returning false in the 'onBeforeDrop' event will abort the dropping action. The code below shows how to disable the dnd on different levels.
Code:
$('#tt').tree({
  onBeforeDrop:function(target,source,point){
    if (point=='append'){
      return false;
    }
    var p1 = $(this).tree('getParent', target);
    var p2 = $(this).tree('getParent', source.target);
    p1 = p1==null ? null : p1.target;
    p2 = p2==null ? null : p2.target;
    if (p1 != p2){
      return false;
    }
  }
})


Title: Re: Tree drag&drop (disable children)
Post by: Szoron on November 22, 2016, 02:15:31 AM
perfect!

thank you!