Access frame in layout

Hi,

I’m trying out the layout module and I’m having some difficulties accessing one of the frames added to the layout.

I’m trying to call a function “switchView” inside one of the frames when a submenu item is clicked. The click event fires as it is supposed to, but I am unable to correctly address the frame, here is the code:

[code]var main_layout = new dhtmlXLayoutObject(document.body, ‘2E’, ‘dhx_skyblue’);

var a = main_layout.cells(‘a’);
a.setHeight(‘100’);
a.hideHeader();

var b = main_layout.cells(‘b’);
b.hideHeader();
var layout_1 = b.attachLayout(‘2U’);

var cell_1 = layout_1.cells(‘a’);
cell_1.setText(‘Navigation’);
cell_1.setWidth(‘280’);
cell_1.attachURL(‘about:blank’);

var cell_2 = layout_1.cells(‘b’);
cell_2.hideHeader();
var layout_2 = cell_2.attachLayout(‘2E’);

cell_4 = layout_2.cells(‘a’);
cell_4.setText(‘Browser’);
cell_4.setHeight(‘200’);
cell_4.attachURL(‘right_top_view.html’);
var menu_1 = cell_4.attachMenu();
menu_1.setIconsPath(‘dhtmlxMenu/codebase/imgs/’);

menu_1.setIconsPath(“icons/16/”);

menu_1.loadXMLString(getMenuXml());

menu_1.attachEvent(“onClick”, function (id, zoneId, casState)
{
if (id.toLowerCase() == “menu_view_large_icons”)
{
layout_2.cells(‘a’)._frame.contentWindow.switchView(‘some_argument’);
}
else if (id.toLowerCase() == “menu_view_detailed_grid”)
{
layout_2.cells(‘a’)._frame.contentWindow.switchView(‘some_other_argument’);
}

return true;

});[/code]

Hope someone can pinpoint the problem for me :slight_smile:

PS. I tried to make main_layout and layout_2 global, but it doesn’t change anything. The error remains “contentWindow is null or undefined”. (testing in IE9).
The function “getMenuXml” just returns some hard coded xml for the menu.

/Aidal

Hi
Replace ._frame. with .getFrame().

This approach isn’t supported any more, it is from an old version.

Ok thanks, I’ll try the new syntax.

You might wanna take a look at the documentation since it includes sample code using the old syntax.
docs.dhtmlx.com/doku.php?id=dhtm … lattaching

Сorrected. :slight_smile: