There are three ways of initializing dhtmlxLayout:
The first things that need to be done for any type of dhtmlxLayout's initialization are the following:
<head> <script src="[full path to this file]/dhtmlxcommon.js"></script> <!-- dhtmlxLayout --> <link rel="stylesheet" type="text/css" href="[full path to this file]/dhtmlxlayout.css"> <link rel="stylesheet" type="text/css" href="[full path to this file]/dhtmlxlayout_dhx_blue.css"> <script src="[full path to this file]/dhtmlxcommon.js"></script> <script src="[full path to this file]/dhtmlxcontainer.js"></script> <script src="[full path to this file]/dhtmlxlayout.js"></script> </head>
Note: dhx_skyblue is the default skin. If the user chooses to apply some other skin, he should indicate path to the appropriate dhtmlxlayout_[name_of_the_skin].css file from dhtmlxLayout package.
If the user works with all available visible space, we recommend him to specify the following style for the <body> tag to make dhtmlxLayout and dhtmlxWindows work correctly:
<style> html, body { width: 100%; height: 100%; margin: 0px; overflow: hidden; } </style>
From this point further steps the user should take are different for every kind of initialization.
We need to create an object where dhtmlxLayout will be placed later. In this example the object is a <div> element on page which is placed in the <body> tag:
<div id="parentId" style="position:absolute; width:600px; height:400px;"></div>
The next step is to create a new dhtmlXLayoutObject and place it after the <div> element (object) that we've just created. The initialization can be done either through objectId (as the first argument):
<script> var dhxLayout = new dhtmlXLayoutObject("parentId", "3L", "dhx_black") </script>
or through object (as the first argument):
<script> var obj = document.getElementById("parentId"); var dhxLayout = new dhtmlXLayoutObject(obj, "3L", "dhx_black"); </script>
The second argument in dhtmlXLayoutObject() is the code of the Layout's pattern.
The third argument is optional, and it indicates the name of the skin chosen for the Layout. If this argument is not indicated, the component will be created with the default skin (dhx_skyblue).
For this type of initialization, the user needs to create a dhtmlxWindows object:
<script> var dhxWins = new dhtmlXWindows(); var layoutWin = dhxWins.createWindow("w1", 20, 20, 600, 400); </script>
The following parameters should be passed to dhxWins.createWindow():
Then we get window-based layout by passing a window object into the Layout's constructor. The following line of code should be added to the above mentioned snippet:
var dhxLayout = new dhtmlXLayoutObject(layoutWin, "3L", "dhx_black");
The second argument is the code of the Layout's pattern. The third one is optional, and it indicates the name of the skin chosen for the Layout. If this argument is not indicated, the component will be created with the default skin (dhx_skyblue).
The Layout initialized in this way will occupy the whole visible screen area in the browser:
<script> var dhxLayout = new dhtmlXLayoutObject(document.body, "3L", "dhx_black"); </script>
The first argument for dhtmlXLayoutObject() in this case should be “document.body”. The second one - the code of the Layout's pattern. The third argument is optional, and it indicates the name of the skin chosen for the Layout. If this argument is not indicated, the component will be created with the default skin (dhx_skyblue).
This type of initialization means that some Layout's cell will be made parent for the newly created Layout. First, the user needs to create a new dhtmlXLayoutObject, indicate its pattern type and skin (optional):
<script> var dhxLayout = new dhtmlXLayoutObject("parentId", "3L"); </script>
Then another dhtmlXLayoutObject will be created, and it's parent should be indicated either through cells or through items:
<script> var Layout1 = new dhtmlXLayoutObject(dhxLayout.cells("a"), "2U"); // OR var Layout1 = new dhtmlXLayoutObject(dhxLayout.items[1], "2U"); </script>
Refer to Items Accessing section for more information on cells and items.
<html> <head> ... <script> var dhxLayout; function doOnLoad() { dhxLayout = new dhtmlXLayoutObject(...); } </script> </head> <body onload="doOnLoad();"> ... </body> </html>
<html> <head> ... <style> html, body { width: 100%; height: 100%; margin: 0px; overflow: hidden; } </style> <script> var dhxLayout; function doOnLoad() { dhxLayout = new dhtmlXLayoutObject(...); } </script> </head> <body onload="doOnLoad();"> ... </body> </html>