Start Building Professional
Web Apps Today


 
Categories Question details Back To List
Question  posted by Scott on Jan 23, 2009 02:54
open dhtmlx forum
Tree getting the previous or next node

Hi

i am currently using drag and drop between two trees in sibling mode. When i drop between two nodes i call a drag handler function which gives me the drop node id among other parameters. The drop node id it gives me is the lower of the two nodes i have dragged between. Is there any way to get the upper of the two nodes in the api? I thought i'd ask before i start writing a long function to handle this myself as i cant see a command such as getPrevious () in the api.

thanks
Scott
Answer posted by Support on Jan 23, 2009 03:50
If you need to get previous item in hierarchy it can be done through inner methods as 

var prev = tree._getPrevNode(tree._idpull[ID]);
if (prev) alert(prev.id);

where ID - id of item for which sibling need to be located

If you just need to get previous item on the same level - you can use 

var index = tree.getIndexById(id);
var prev = tree.getItemIdByIndex(tree.getParentId(id),index-1);