DHTMLX Docs & Samples Explorer

Id-Index Interconnection

Get ID by Index     Get Index by ID
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 id="srcDiv" style="position: relative; margin-top: 40px; left: 20px; width: 600px;">
    Get ID by Index <select id="inds"></select> <input type="button" value="Get ID" onclick="getId();">
    &nbsp;&nbsp;&nbsp;
    Get Index by ID <select id="ids"></select> <input type="button" value="Get Index" onclick="getIndex();">
</div>
<script>
var dhxLayout,
ids,
inds;
function doOnLoad() {
    dhxLayout = new dhtmlXLayoutObject("parentId", "5I");
    ids = document.getElementById("ids");
    inds = document.getElementById("inds");
    dhxLayout.forEachItem(function(item) {
        ids.options.add(new Option(item.getId(), item.getId()));
        inds.options.add(new Option(item.getIndex(), item.getIndex()));
    });
}
function getId() {
    var ind = inds.options[inds.selectedIndex].value;
    alert(dhxLayout.getIdByIndex(ind));
}
function getIndex() {
    var id = ids.options[ids.selectedIndex].value;
    alert(dhxLayout.getIndexById(id));
}
</script>