DHTMLX Docs & Samples Explorer

Expanding/Collapsing Cells

Item:
Source
<link rel="stylesheet" type="text/css" href="../../codebase/dhtmlxlayout.css">
<link rel="stylesheet" type="text/css" href="../../codebase/skins/dhtmlxlayout_dhx_skyblue.css">
<script src="../../codebase/dhtmlxcommon.js"></script>
<script src="../../codebase/dhtmlxlayout.js"></script>
<script src="../../codebase/dhtmlxcontainer.js"></script>
 
<div id="parentId" style="position: relative; top: 20px; left: 20px; width: 600px; height: 400px; aborder: #B5CDE4 1px solid;"></div>
<div style="position: relative; margin-top: 40px; margin-left: 20px;">
    Item: <select id="sel"></select>
    <input type="button" value="Expand" onclick="expand();">
    <input type="button" value="Collapse" onclick="collapse();">
</div>
<script>
var dhxLayout;
var sel = document.getElementById("sel");
function doOnLoad() {
    dhxLayout = new dhtmlXLayoutObject("parentId", "3L");
    dhxLayout.forEachItem(function(item) {
        sel.options.add(new Option(item.getId(), item.getIndex()));
    });
}
function getInd() {
    var sel = document.getElementById("sel");
    var id = sel.options[sel.selectedIndex].value;
    return id;
}
function expand() {
    dhxLayout.items[getInd()].expand();
}
function collapse() {
    dhxLayout.items[getInd()].collapse();
}
</script>