DHTMLX Docs & Samples Explorer

Moving items

Move from left tree to right tree
Move selected to child
Move selected to sibling

Move from right tree to left tree
Move selected to child
Move selected to sibling

Move inside left tree
Move selected Up | Down | Left
Move selected Up on level | Down on level
Move selected to child of
Move selected to sibling of



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>
            <div id="treeboxbox_tree" style="width:250px; height:218px;background-color:#f5f5f5;border :1px solid Silver;; overflow:auto;"/>
        </td>
        <td>
            <div id="treeboxbox_tree2" style="width:250px; height:218px;background-color:#f5f5f5;border :1px solid Silver;; overflow:auto;"/>
        </td>
        <td rowspan="2" style="padding-left:25" valign="top">
        <div>Move from left tree to right tree</div>
        </div>
        Move selected<a href="javascript:void(0)" onclick="tree.moveItem(tree.getSelectedItemId(),'item_child',tree2.getSelectedItemId(),tree2)"> to child </a></select>
        </div>
        <div>
        Move selected <a href="javascript:void(0)" onclick="tree.moveItem(tree.getSelectedItemId(),'item_sibling',tree2.getSelectedItemId(),tree2)"> to sibling </a></select>
        </div>
        <br/>
        <div>Move from right tree to left tree</div>
        </div>
        Move selected<a href="javascript:void(0)" onclick="tree2.moveItem(tree2.getSelectedItemId(),'item_child',tree.getSelectedItemId(),tree)"> to child </a></select>
        </div>
        <div>
        Move selected <a href="javascript:void(0)" onclick="tree2.moveItem(tree2.getSelectedItemId(),'item_sibling',tree.getSelectedItemId(),tree)"> to sibling </a></select>
        </div>
        <br/>
        <div>Move inside left tree</div>
         <div>
        Move selected <a href="javascript:void(0)" onclick="tree.moveItem(tree.getSelectedItemId(),'up')"> Up </a> | <a href="javascript:void(0)" onclick="tree.moveItem(tree.getSelectedItemId(),'down')">Down</a> | <a href="javascript:void(0)" onclick="tree.moveItem(tree.getSelectedItemId(),'left')"> Left</a>
        <div>
         <div>
        Move selected <a href="javascript:void(0)" onclick="tree.moveItem(tree.getSelectedItemId(),'up_strict')"> Up on level </a> | <a href="javascript:void(0)" onclick="tree.moveItem(tree.getSelectedItemId(),'down_strict')">Down on level</a>
        <div>
        </div>
        Move selected <a href="javascript:void(0)" onclick="tree.moveItem(tree.getSelectedItemId(),'item_child',this.nextSibling.value)"> to child of </a><select><option value="books">Books</option><option value="sport">Sport</option><option value="magazines">Magazines</option></select>
        </div>
        <div>
        Move selected <a href="javascript:void(0)" onclick="tree.moveItem(tree.getSelectedItemId(),'item_sibling',this.nextSibling.value)"> to sibling of </a><select><option value="books">Books</option><option value="sport">Sport</option><option value="magazines">Magazines</option></select>
        </div>
        </td>
    </tr>
</table>
<br>
<script>
tree = new dhtmlXTreeObject("treeboxbox_tree", "100%", "100%", 0);
tree.setSkin('dhx_skyblue');
tree.setImagePath("../../codebase/imgs/csh_bluefolders/");
tree.enableSmartXMLParsing(true);
tree.loadXML("../common/tree_a.xml");
 
tree2 = new dhtmlXTreeObject("treeboxbox_tree2", "100%", "100%", 0);
 
tree2.setSkin('dhx_skyblue');
tree2.setImagePath("../../codebase/imgs/csh_bluefolders/");
tree2.enableSmartXMLParsing(true);
tree2.loadXML("../common/tree_a.xml");
</script> <br><br>