Work with Layout

Removing cells

To remove a certain cell from a layout, apply the removeCell method. As a parameter it takes the id of a cell to be removed:

layout.removeCell(id);

Related sample:  Remove cell - DHTMLX Layout

Getting the object of a cell

You can get the object of some cell by its id. Use the getCell method for this purpose:

layout.getCell("1");

Attaching a component to a cell

You can easily attach any DHTMLX component to a cell of Layout using the attach method of a cell:

var list = new dhx.List(null, {
    template: listTemplate,
    itemHeight: 52,
    height: "100%",
    dragMode: "both"
});
 
list.data.load('../common/library.json');
 
layout.cell("list").attach(list);

Related sample:  Attach - DHTMLX Layout

Hiding/showing a cell

It is possible to hide/show a cell with the help of its API. Both the hide and show methods take the id of a cell as a parameter.

// hiding a cell
layout.cell("1").hide();

Related sample:  Hide - DHTMLX Layout

// showing a cell
layout.cell("1").show();

Related sample:  Show - DHTMLX Layout

Checking visibility of a cell

Since the object of a cell has the hidden attribute, a cell can be hidden in a layout. You can check the visibilty of cell via the isVisible method. It returns true if a cell is visible and false if it is hidden.

layout.cell("1").isVisible(); // -> true|false

Collapsing/expanding a cell

You can collapse/expand a specified cell using two corresponding methods of a Layout cell - collapse() and expand():

// collapsing a cell by its id
layout.cell("id").collapse();
 
// expanding a cell by its id
layout.cell("1").expand();

Related sample:  Expand/collapse - DHTMLX Layout

Toggling a cell

It is also possible to collapse and expand a specified cell of Layout using the toggle() method of a cell:

layout.cell("id").toggle();

Related sample:  Toggle - DHTMLX Layout

Back to top