从一个dhtmlxTree拖放到另一个

时间:2015-11-27 15:56:17

标签: tree drag-and-drop dhtmlx

我正试图从一个dhtmlxTree拖放到另一个。我只想拖动所选项目而不是所选项目的兄弟姐妹,我该如何处理? 我已经有了下一个:

tree = new dhtmlXTreeObject("tree_1","100%","100%",0);
tree.setImagePath("codebase/imgs/dhxtree_skyblue/");
tree.enableDragAndDrop(true);      //any
tree.loadXML("tree_dnd.xml");
tree.attachEvent("onDrag", function(sId, tId, id, sObject, tObject){
    return false
});
tree2 = new dhtmlXTreeObject("tree_2","100%","100%",0);
tree2.setImagePath("codebase/imgs/dhxtree_skyblue/");
tree2.enableDragAndDrop(true);
tree2.loadXML("tree_dnd.xml");

1 个答案:

答案 0 :(得分:0)

您可以这样做:

tree2.attachEvent("onDrag", function(sId, tId, id, sObject, tObject){
    if (sObject == tObject){
        return false;
    }
    else {
        tree2.insertNewItem(tId, id+"_new", tree.getItemText(sId));
        return false;
    }
});