Attach a layout to a tabbar

Hi,
I wan’t to develop layout in other files and after attach layout to a tabbar, but in docs there a just:

// pattern only
var myLayout = myTabbar.tabs(id).attachLayout("4H");
 
// api-init config
var myLayout = myTabbar.tabs(id).attachLayout({
    pattern: "4H",
    cells: [
        {id: "a", text: "Navigation", width: 100, header: false},
        {id: "b", text: "Advertisement", height: 100},
        {id: "c", text: "Main Page"},
        {id: "d", text: "Links", collapse: true}
    ]
});

So we have to create a new layout when we wan’t to attch one ?
Can we attach a existing layout ?

Thank you :slight_smile:

Hello.
Yes, but it is necessary in the beginning to create the layout, then create a tabbar, in tabbare create tabs, they put you layout.

Example:
window.dhx4.skin = ‘dhx_web’;
var main_layout = new dhtmlXLayoutObject(document.body, ‘1C’);

var a = main_layout.cells('a');
var tabbar_1 = a.attachTabbar();
tabbar_1.addTab('tab_2','tab_2');
var tab_2 = tabbar_1.cells('tab_2');
var layout_1 = tab_2.attachLayout('3E');

Thank you for your answer, but in your example I don’t see where you attach an existing layout :slight_smile:
because you create a tabbar in a cell of a layout, and you put a new layout in the tabBar, me I wan’t to do something like :

var layout_1 = tab_2.attachLayout(layoutInAnOtherFile);

and not :

var layout_1 = tab_2.attachLayout('3E');

because here you create a new layout no ?

thank you :slight_smile:

explain in more detail that you want? what shall be result after execution of a code and how shall look?

I found what I wan’t !
we cannot do what I said because we have to use attachURL !

thank you but I didin’t think about attachURL sorry :slight_smile:

Hi,

The api of components do not allow to attach the already existing layout to the cell of other component.
You need to use .attachSome api if you want to create a subcomponent inside of the parent one.