Hi,
I am using dhtmlxtree in my applicaion. I need to drag all the childrens only by dragging the parent node. How to do that?
For example, I have a tree
(-)2008
------ january
– page1
– page2
----- february
– page3
---- march
– page4
(-) 2009
------ january
– page5
– page6
----- february
– page7
---- march
– page8
Here i need to drag node 2008, but it should drag and drop the leaf childrens only. here page1, page2, page3, page4.
Suppose if I drag the node january , then it should drag and drop page1,page2 only. how to do that? Acually i am getting all the leaf nodes using var totalIDs=holidaytree.getAllSubItems(idFrom).split(“,”);
Please help me.
thanks,
Velmurugan.
Hello,
you can try to use the following approach:
tree.attachEvent(“onDrag”,function(sid,tid){
if(tree.hasChildren(sid)) addItems(sid,tid)
return false
})
function addItems(sid,tid,sobj,tobj){
var childs = tree.getAllSubItems(sid).split(",");
for(var i=0; i< childs.length; i++)
if(!tree.hasChildren(childs[i])){
tree.insertNewItem(tid,childs[i],tree.getItemText(childs[i]))
tree.deleteItem(childs[i])
}
}
Gr8… thanks alex. It is working fine. I have 1 more doublt. how do i know that from which tree i am dragging? any identification or relationship between tree and its node?
onDrag event handler gets more parameters:
1- source id;
2- target id;
3- before drag id;
4- source tree object
5- target tree object
So, you can use 4th and 5th parameters to identify tree.