DHTMLX Docs & Samples Explorer

Temporary disabling Drag&Drop

There is a functionality in dhtmlxTree which provides you temporary disabling drag-and-drop. You can apply it for both child and sibling drop modes.

drop as child
drop as sibling
Enable Drag and Drop
Disable Drag and Drop
Enable Drag and Drop
Disable Drag and Drop


Source
<link rel="STYLESHEET" type="text/css" href="../../codebase/dhtmlxtree.css">
<script  src="../../codebase/dhtmlxcommon.js"></script>
<script  src="../../codebase/dhtmlxtree.js"></script>    
 
 
<table>
    <tr>
        <td>
            drop as child
            <div id="treeboxbox_tree" style="width:250px; height:218px;background-color:#f5f5f5;border :1px solid Silver;"/>
        </td>
        <td style="padding-left:25" valign="top">
            drop as sibling
            <div id="treeboxbox_tree2" style="width:250px; height:218px;background-color:#f5f5f5;border :1px solid Silver;"/>
        </td>
    </tr>
    <tr>
        <td>
            <a href="#"><div style='cursor:pointer;' onClick="tree.enableDragAndDrop(true)">Enable Drag and Drop</div></a>
            <a href="#"><div style='cursor:pointer;' onClick="tree.enableDragAndDrop('temporary_disabled')">Disable Drag and Drop</div></a>
        </td><td style="padding-left:25" >
            <a href="#"><div style='cursor:pointer;' onClick="tree2.enableDragAndDrop(true)">Enable Drag and Drop</div></a>
            <a href="#"><div style='cursor:pointer;' onClick="tree2.enableDragAndDrop('temporary_disabled')">Disable Drag and Drop</div></a>
        </td>
    </tr>
</table>
<script>
tree = new dhtmlXTreeObject("treeboxbox_tree", "100%", "100%", 0);
tree.setSkin('dhx_skyblue');
tree.setImagePath("../../codebase/imgs/csh_yellowbooks/");
tree.enableDragAndDrop("temporary_disabled");
tree.enableSmartXMLParsing(true);
tree.loadXML("../common/tree_05_drag_n_drop.xml");
tree2 = new dhtmlXTreeObject("treeboxbox_tree2", "100%", "100%", 0);
 
tree2.setSkin('dhx_skyblue');
tree2.setImagePath("../../codebase/imgs/csh_yellowbooks/");
tree2.enableSmartXMLParsing(true);
tree2.enableDragAndDrop(true);
tree2.setDragBehavior("sibling");
tree2.loadXML("../common/tree_05_drag_n_drop.xml");
</script> <br><br>