Almost all DHTMLX components can be attached directly to a cell by the corresponding method.
Accordion |
|
Carousel |
|
Chart |
|
DataView |
|
Editor |
|
Form |
|
Grid |
|
Layout |
|
List |
|
Menu |
|
Ribbon |
|
Scheduler |
|
Sidebar |
|
StatusBar |
|
Tabbar |
|
Toolbar |
|
Tree |
|
TreeView |
|
We highly recommend you to follow this way of attaching components, as it guarantees proper rendering and correct resizing of embedded components in relation to their parent container.
Please note that attaching of Menu, Ribbon, Toolbar and StatusBar into a cell has some peculiarities. For details check the article Attaching Menu/Status Bar.
Make sure you've included the corresponding .js/.css files of the related component on a page, for example:
<head>
<link rel="stylesheet" type="text/css" href="dhtmlxgrid.css">
<script src="dhtmlxgrid.js"></script>
</head>
There is a possibility to get link to the attached component:
var attached = dhxComponent.cells(id).getAttachedObject();
if (window.dhtmlXGridObject != null && attached instanceof window.dhtmlXGridObject) {
console.log("An attached grid detected");
}
// attach
var myAcc = dhxComponent.cells(id).attachAccordion({...});
// detach later
dhxComponent.cells(id).detachObject(true);
myAcc = null;
Please note, the attachScheduler method differs from other attaching methods. The difference is that attachScheduler not only attaches the component but also initializes it - creates an instance with the predefined structure.
Therefore:
var myLayout = new dhtmlXLayoutObject(document.body, "3L");
myLayout.cells("a").setWidth(800);
// configure scheduler if needed
scheduler.config.xml_date = "%Y-%m-%d %H:%i";
// then attach it to layout
myLayout.cells("a").attachScheduler(new Date(), "month");
// load some data
scheduler.load("../common/events.xml");
Back to top