DHTMLX Docs & Samples Explorer

Docking/Undocking Items To/From Windows

Select Item
Source
<script src="../../codebase/dhtmlxcommon.js"></script>
<script src="../../codebase/dhtmlxaccordion.js"></script>
<link rel="stylesheet" type="text/css" href="../../codebase/skins/dhtmlxaccordion_dhx_skyblue.css">
<link rel="stylesheet" type="text/css" href="../../../dhtmlxWindows/codebase/dhtmlxwindows.css">
<link rel="stylesheet" type="text/css" href="../../../dhtmlxWindows/codebase/skins/dhtmlxwindows_dhx_skyblue.css">
<script src="../../../dhtmlxWindows/codebase/dhtmlxwindows.js"></script>
<script src="../../../dhtmlxWindows/codebase/engine/dhtmlxwindows_enginedhx.js"></script>
<script src="../../codebase/dhtmlxcontainer.js"></script>
 
<div id="winVP" style="position: relative; height: 500px; width: 600px; margin: 10px;">
<div id="accordObj" style="position: relative; width: 320px; height: 400px;"></div>
</div>
<div style="margin: 50px 0px 20px 0px;">
Select Item <select id="sel"></select> <input type="button" value="Dock" onclick="dock();"> <input type="button" value="Undock" onclick="undock();">
</div>
<script>
var sel,
dhxAccord;
function init() {
    sel = document.getElementById("sel");
    dhxAccord = new dhtmlXAccordion("accordObj");
    dhxAccord.dhxWins.enableAutoViewport(false);
    dhxAccord.dhxWins.attachViewportTo("winVP");
    dhxAccord.addItem("a1", "a");
    dhxAccord.addItem("a2", "b");
    dhxAccord.addItem("a3", "c");
    dhxAccord.openItem("a1");
    dhxAccord.forEachItem(function(item) {
        sel.options.add(new Option(item.getText(), item.getId()));
    });
}
function getId() {
    var id = sel.options[sel.selectedIndex].value;
    return id;
}
function dock() {
    dhxAccord.cells(getId()).dock();
}
function undock() {
    var id = getId();
    dhxAccord.cells(id).undock();
    dhxAccord.dhxWins.window(id).keepInViewport(true);
}
</script>