Check documentation for the latest version of dhtmlxSuite detachObject DHTMLX Docs

detachObject

detaches any attached content from a cell

void detachObject( [boolean remove,string|number|HTMLElement moveTo] );
removeboolean(optional) set to true to remove the content permanently, false by default
moveTostring|number|HTMLElement(optional) the object's id or the object itself to move content to (if the "remove" parameter is set to false)
Details

Let's consider possible behavior, depending on which we pass particular parameters to the method.

Assuming that we have attached Grid to the component's cell:

var myGrid = dhxComponent.cells(id).attachGrid();

In case we need to detach Grid later, there are several possible options:

1) calling the detachObject() method without parameters:

dhxComponent.cells(id).detachObject();

The Grid object won't be completely removed. It will be attached to the document.body outside the component's container and hidden with the display:none property.

2) calling the detachObject() method with the "remove" parameter set to true:

dhxComponent.cells(id).detachObject(true);

The cell will be cleared. You need to clear the Grid object to remove it permanently.

myGrid = null;

3) calling the detachObject() method with the "remove" parameter set to false and passing an object (object's id) as the second parameter:

// assuming that a node with the id="tempNode" exists
dhxComponent.cells(id).detachObject(false, "tempNode");

The Grid object won't be completely removed. It will be moved to the "tempNode" container and hidden with the display:none property.

Note also that if you call dhxComponent.unload(), the attached content will be removed permanently.

See also
Back to top