I have a javascript variable where i hold a grid. This grid is initialy created as a …cells(“b”).attachGrid() call. I then toggle view of this cell to be a graph and detach the grid from the layout cell and attach the graph html element. Now i want to switch the graph out for the grid again and there is no way for me to just say:
mygrid = //grid created before but now not attached to the layout
layout.cells("b").detachObject();
layout.cells("b").attachObject(mygrid);//throws an error
/*
Node cannot be inserted at the specified point in the hierarchy" code: "3
*/
I think this post make sense but please ask if there is anything thats not clear.
attachObject requires html container as parameter. Therefore, it is impossible to use:
layout.cells(“b”).attachObject(mygrid);
detachObject returns a dhtmlx component and its container. Therefore, you may use the following:
var arr = layout.cells(“b”).detachObject();
if(arr.length)
layout.cells(“b”).attachObject(arr[1]);
However, in this case the handlers that resizes grid when layout cell is resized won’t be preserved.
To enable them you may use the following:
layout.cells(“b”).vs[“def”].grid = mygrid;
So, the complete approach:
var arr = layout.cells("b").detachObject();
if(arr.length){
layout.cells("b").attachObject(arr[1]);
layout.cells("b").vs["def"].grid = mygrid;
}
Also you may use views instead - please read about them in the documentation:
Hello, nburnsPF
To avoid menu disappearing you can attach menu as global item in layout: dhtmlx.com/docs/products/dht … _menu.html
Hello, junb1
If i understood you right, you can try method “moveContentTo”
Like the next: dhxLayout1.cells(“a”).moveContentTo(dhxLayout2.cells(“a”));
to move grid from cell A to cell B