DHTMLX Docs & Samples Explorer

Using dhtmlxLayout and dhtmlxWindows together

Sometimes when using layout you may need to show a pop-up window. To do this you should first create an instance of dhtmlxWindows and then create a window. But as far as layout is based on windows as well, you can use a dhtmlxWindows instance that has been already created by layout. To achieve this you should do the following:

    // creating layout instance
    var dhxLayout = new dhtmlXLayoutObject("3L");
    ...
    // creating pop-up window from layout's dhtmlxWindows' instance
    var popupWindow = dhxLayout.dhxWins.createWindow("popupWindow", ...);

This allows you to reduce used memory and increase script's performance.

Note: There are cases when some windows' ids are already used by layout so you can't use them for creating another windows. How to identify the id you are not allowed to use? Take for example a layout with 3 cells called “a”, “b” and “c”. Windows' ids used for them are “a”, “b” and “c”. Windows's ids for the layout with 5 cells could be called “a”, “b”, “c”, “d” and “e”. None of these ids can not be used.

There is a function which allows you to check availability of any “id”:

    // check if id in use
    if (dhxLayout.dhxWins(id)) {
        // id is already in use, checked id can not be used for new window
    } else {
        // id is free for use
    }