EasyUI Forum
September 14, 2025, 03:27:52 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: The Sequence of the Child Nodes in Tree  (Read 8067 times)
leela
Newbie
*
Posts: 29


View Profile Email
« on: July 08, 2014, 02:40:51 PM »

Hi,

 I need to identify the sequence of the child nodes of a given node.
 Lets say I have a tree, with drag and drop enabled.
 When the user drags and drops a node with in same parent, and changes its position.
 how do I save that sequence change in the node, under that parent.

 Any response is greatly appreciated.

Thanks,
Leela.
 
Logged
stworthy
Administrator
Hero Member
*****
Posts: 3581


View Profile Email
« Reply #1 on: July 09, 2014, 01:43:06 AM »

After drag and drop a node, the 'onDrop' event fires, in which you can save the node sequence to the database.
Code:
$('#tt').tree({
onDrop: function(target, source, point){
//the 'point' indicates the drop operation, posible values are: 'append','top' or 'bottom'
}
})
Logged
leela
Newbie
*
Posts: 29


View Profile Email
« Reply #2 on: July 09, 2014, 07:52:03 AM »

How can I calculate the order and update it for all the elements in the node, based on the re-ordering due to drag and drop.
Is there an attribute for a node, that represents its position in the tree and under its parent?
Logged
stworthy
Administrator
Hero Member
*****
Posts: 3581


View Profile Email
« Reply #3 on: July 09, 2014, 09:12:40 AM »

You don't need to calculate the order for the nodes, the tree plugin has done all for you. Call 'getData' method to get a parent node's data, all the children nodes are in their order.
Code:
var t = $('#tt')
var s = t.tree('getSelected');
$.map(t.tree('getData',s.target).children, function(node){
console.log(node.text)
})
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!