DHTMLX Docs & Samples Explorer

Events onDock/onUnDock

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; 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>
<div id="ta" style="position: relative; width: 320px; margin-top: 20px; height: 100px; overflow: auto;"></div>
<script>
var ta,
dhxAccord,
sel;
function doOnLoad() {
    ta = document.getElementById("ta");
    dhxAccord = new dhtmlXAccordion("accordObj");
    dhxAccord.dhxWins.enableAutoViewport(false);
    dhxAccord.dhxWins.attachViewportTo("winVP");
    //dhxAccord.enableMultiMode(true);
    dhxAccord.attachEvent("onDock", function(itemId) {
        ta.innerHTML = "Item <b>" + dhxAccord.cells(itemId).getText() + "</b> was docked<br>" + ta.innerHTML;
    });
    dhxAccord.attachEvent("onUnDock", function(itemId) {
        ta.innerHTML = "Item <b>" + dhxAccord.cells(itemId).getText() + "</b> was undocked<br>" + ta.innerHTML;
    });
    dhxAccord.addItem("a1", "a");
    dhxAccord.addItem("a2", "b");
    dhxAccord.addItem("a3", "c");
    dhxAccord.addItem("a4", "d");
    dhxAccord.openItem("a1");
    sel = document.getElementById("sel");
    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>