EasyUI Forum
September 13, 2025, 11:10:22 PM *
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 and action on move node  (Read 19649 times)
nhobbes
Newbie
*
Posts: 6


View Profile
« on: August 07, 2012, 12:57:58 AM »

Hello,

I'lm a new user of jquery and easyUI.
I find how to build a tree with movable nodes but i'm searching how to do something on drag and drop action.

What I want to do is to save the new configuration each time I do an action on the tree.

Also I would like to disable an action : a leaf become a node if you drop something on it and a node become a leaf if it has no leaf. Is it possible ?

Thanks a lot for your help
« Last Edit: August 07, 2012, 12:59:58 AM by nhobbes » Logged
stworthy
Administrator
Hero Member
*****
Posts: 3581


View Profile Email
« Reply #1 on: August 07, 2012, 05:25:19 PM »

When drag and drop a node, the 'onDrop' event will be triggered, in which you can save the tree node state to server.
Code:
<ul id="tt2" class="easyui-tree" data-options="url:'tree_data.json',
dnd:true,
onDrop:function(target,source,point){
var targetNodeId = $(this).tree('getNode',target).id;
var sourceNodeId = source.id;
$.post(url, {
targetNodeId: targetNodeId,
sourceNodeId: sourceNodeId,
point: point
}, function(){
alert('save ok');
});
}"></ul>
Logged
nhobbes
Newbie
*
Posts: 6


View Profile
« Reply #2 on: August 08, 2012, 01:19:42 AM »

Thanks a lot for your answer. It works fine.

Do you know how to disable the drop function on a leaf ?
Logged
nhobbes
Newbie
*
Posts: 6


View Profile
« Reply #3 on: August 08, 2012, 02:05:14 AM »

I think I found almost it.
I had a test in the function appliying droppable class. The only problem is that I can't move a node on top or bottom of another now.
Do you know a way to do that ?
« Last Edit: August 08, 2012, 02:08:52 AM by nhobbes » Logged
nhobbes
Newbie
*
Posts: 6


View Profile
« Reply #4 on: August 26, 2012, 11:30:09 PM »

Somebody already do something like this ? I can't find a way to disable dropping on a node.
Logged
stworthy
Administrator
Hero Member
*****
Posts: 3581


View Profile Email
« Reply #5 on: August 27, 2012, 02:28:39 AM »

To disable dropping on a node, try changing its accept property.
Code:
var node = $('#tt').tree('find', nodeId);  // get the node
$(node.target).droppable({accept:'no-accept'});  // change the node's accept property, so that it will not allowed dropping on it
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!