DHTMLX Docs & Samples Explorer

User-Button

Select Button
Select Action
Source
<link rel="stylesheet" type="text/css" href="../../codebase/dhtmlxwindows.css">
<link rel="stylesheet" type="text/css" href="../../codebase/skins/dhtmlxwindows_dhx_skyblue.css">
<script src="../../codebase/dhtmlxcommon.js"></script>
<script src="../../codebase/dhtmlxwindows.js"></script>
 
<script src="../../codebase/dhtmlxcontainer.js"></script>
 
<div>
<table>
    <tr>
        <td style="padding-right: 10px;">Select Button</td>
        <td>
            <select id="sel1" disabled>
                <option value="dock">Dock</option>
            </select>
        </td>
    </tr>
    <tr>
        <td style="padding-right: 10px;">Select Action</td>
        <td>
            <select id="sel2">
                <optgroup label="visibility">
                    <option value="show">Show</option>
                    <option value="hide">Hide</option>
                    <option value="isHidden">isHidden</option>
                </optgroup>
                <optgroup label="access">
                    <option value="enable">Enable</option>
                    <option value="disable">Disable</option>
                    <option value="isEnabled">isEnabled</option>
                </optgroup>
            </select>
        </td>
    </tr>
    <tr>
        <td colspan="2" align="center" style="padding-top: 10px; padding-bottom: 10px;"><input type="button" value="Apply" onclick="executeScript();"></td>
    </tr>
</table>
</div>
<div id="winVP" style="position: relative; height: 500px; border: #cecece 1px solid; margin: 10px;"></div>
<script>
var dhxWins,
w1;
function doOnLoad() {
    dhxWins = new dhtmlXWindows();
    dhxWins.enableAutoViewport(false);
    dhxWins.attachViewportTo("winVP");
    dhxWins.setImagePath("../../codebase/imgs/");
    w1 = dhxWins.createWindow("w1", 20, 30, 320, 240);
    w1.setText("dhtmlxWindow");
    w1.button("close").disable();
    w1.addUserButton("dock", 0, "Dock Window", "dock");
    w1.button("dock").attachEvent("onClick", function() {
        alert('The window wants to be docked.');
    });
}
function executeScript() {
    if (dhxWins.window("w1") == null) {
        return;
    }
    var sel1 = document.getElementById("sel1");
    var btn = (sel1.options[sel1.selectedIndex].value).split(",");
    var sel2 = document.getElementById("sel2");
    var action = sel2.options[sel2.selectedIndex].value;
    switch (action) {
    case "show":
        ;
        w1.button(btn[0]).show();
        break;
    case "hide":
        ;
        w1.button(btn[0]).hide();
        break;
    case "isHidden":
        ;
        alert(w1.button(btn[0]).isHidden());
        break;
    case "enable":
        ;
        w1.button(btn[0]).enable();
        break;
    case "disable":
        ;
        w1.button(btn[0]).disable();
        break;
    case "isEnabled":
        ;
        alert(w1.button(btn[0]).isEnabled());
        break;
    }
}
</script>