object referencing - head init


#1

Hello,

Newbie qestion:

if i make a fullscreen init in the head section -> how i can reference to the dhtmlx-objects in a script in body?

<head>
<script type="text/javascript">
window.onload = function(){
dhtmlx.image_path='./codebase/imgs/';
var main_layout = new dhtmlXLayoutObject(document.body, '2E');
var a = main_layout.cells('a');
var tabbar_1 = a.attachTabbar();
tabbar_1.addTab('tab_1','HEQ-Übersicht','');
var tab_1 = tabbar_1.cells('tab_1');
tabbar_1.setTabActive('tab_1');
var grid_1 = tab_1.attachGrid();
grid_1.setIconsPath('./codebase/imgs/');
grid_1.setSkin("dhx_skyblue");
//grid_1.enableAlterCss("even", "uneven");
grid_1.enableRowsHover(true,'grid_hover')
grid_1.init();
var b = main_layout.cells('b');
b.setText("HEQ-Detailinformation");
main_layout.setCollapsedText("b", "HEQ-Info");
b.setHeight(200);
b.collapse();
</script>
</head>
<body>
<script type="text/javascript">
<<Script to work with dhtmlx-objects>>
</script>
</body>
</html>

Questions:
:blush: - how can i, for example, adress the grid for loading a xml?
:blush: - what is the best way to initialize dhtmlx on a webpage?

Thanx for your help!


#2

You need to store reference to them ( or at least to the top layout ) in the global var

Instead of
var main_layout = new dhtmlXLayoutObject(document.body, ‘2E’);
use
main_layout = new dhtmlXLayoutObject(document.body, ‘2E’);

And you will be able to use main_layout through your code to access the layout object, similar approach can be used with grid and other components. ( you can access all objects in layout through top layout object, but using direct reference is more simple and error proof approach )