Copy and paste in the dhtmlxTree

I am generating two trees dynamically (both five levels) in dhtmlxLayout. I want copy and paste the node of the from left tree to right node for that I am using tree.enableMercyDrag(true); in left tree, its working well. But I want to lock first two levels of both tree and please let me know how to use tree.attachEvent(“onDrag”,function(sid,tid) ) means the method to get sid and tid .



My tree like below



Class

---- Subclass

-------- Requirement

------------FM

----------------FMC



In this tree I want to lock first two nodes which could not be drag and drop from tree .



The code I used to generate tree is given below



var tree, newTree;

var dhxLayout = new dhtmlXLayoutObject(“parentId”, “2U”);

dhxLayout.cells(“a”).hideHeader();

dhxLayout.cells(“a”).setWidth(325);

dhxLayout.cells(“b”).hideHeader();





function loadTree()

{

project_id=document.getElementById(“p_id”).value;

sys_id=document.getElementById(“s_id”).value;

tree = dhxLayout.cells(“a”).attachTree(0);

tree.setImagePath(“dhtmlx/dhtmlxTree/samples/images/”);

tree.enableCheckBoxes(false);

tree.enableTreeLines(false);

tree.enableMultiLineItems(true);

tree.enableAutoTooltips(true);

tree.preventIECaching(true);

tree.enableDragAndDrop(true);

tree.enableMercyDrag(true);

tree.enableSmartXMLParsing(true);

tree.setXMLAutoLoading(“XML/fmea_tree.jsp?project_id=”+project_id+"&sys_id="+sys_id);

tree.loadXML(“XML/fmea_tree.jsp?project_id=”+project_id+"&sys_id="+sys_id,autoselectNode);

            

            

newTree = dhxLayout.cells(“b”).attachTree(0);

newTree.setImagePath(“dhtmlx/dhtmlxTree/samples/images/”);

newTree.enableCheckBoxes(false);

newTree.enableTreeLines(false);

newTree.enableMultiLineItems(true);

newTree.enableAutoTooltips(true);

newTree.preventIECaching(true);

newTree.enableDragAndDrop(true);

newTree.enableSmartXMLParsing(true);

newTree.setXMLAutoLoading(“XML/fmea_tree.jsp?project_id=”+project_id+"&sys_id="+sys_id);

newTree.loadXML(“XML/fmea_tree.jsp?project_id=”+project_id+"&sys_id="+sys_id,autoselectNode);

}

You can block drag of element as
tree.attachEvent(“onBeforeDrag”,function(id){
if (id = “class” ) return false; //or any other necessary id
return true;
});

You can block drop on element as
tree.attachEvent(“onDragIn”,function(sid,tid){
if (tid = “class” ) return false; //or any other necessary id
return true;
});


>>how to use tree.attachEvent(“onDrag”,function(sid,tid) ) means the method to get sid and tid
tree.attachEvent(“onDrag”,function(sid,tid){
alert(sid);
return true;
})