EasyUI Forum

General Category => General Discussion => Topic started by: shrikantphale on September 26, 2012, 04:15:34 AM



Title: Is it possible to add Ondrag, OndragStart, OndragStop event to 'tree' structure?
Post by: shrikantphale on September 26, 2012, 04:15:34 AM
I want these events to validate whether to allow that particular node to drop or not... plz help...
thanks..


Title: Re: Is it possible to add Ondrag, OndragStart, OndragStop event to 'tree' structure?
Post by: stworthy on September 26, 2012, 11:55:09 AM
Get a tree node and call 'enable' and 'disable' methods provided in draggable to determine if the node can be draggable.

Code:
var node = $('#tt').tree('find', 12);  //find a node
$(node.target).draggable('disable');
$(node.target).draggable('enable');


Title: Re: Is it possible to add Ondrag, OndragStart, OndragStop event to 'tree' structure?
Post by: shrikantphale on September 28, 2012, 03:20:09 AM
Hey... do you have any solution to restrict any node to move away from its parent... and also restrict node to go into any node... in drag drop feature in tree... plz help ASAP....


Title: Re: Is it possible to add Ondrag, OndragStart, OndragStop event to 'tree' structure?
Post by: stworthy on September 28, 2012, 06:39:24 PM
The 'onDragOver' event is available from http://www.jeasyui.com/easyui/plugins/jquery.tree.js. Some codes looks like this:
Code:
$('#tt').tree({
dnd: true,
onDragOver: function(target, source){
var cc = $(this).tree('getChildren',target);
for(var i=0; i<cc.length; i++){
if (cc[i].target == source.target){return false} // return false to deny drop, restrict the node to move away from it parent
}
}
});