Centering a form into a window/layout panel

Hi guys any one of you know how to center a form created within either a window or layout panel?

Hello,

You may try the following code. If there is no vertical/horizontal scrolls - may be usefull.

var form = new dhtmlXForm(...);
//or
var form = dhxLayout.cells(id).attachForm(...);

form.t.style.position="absolute";
form.t.style.width="auto";
form.t.style.marginLeft=-Math.round(form.t.offsetWidth/2)+"px";
form.t.style.marginTop=-Math.round(form.t.offsetHeight/2)+"px";
form.t.style.left="50%";
form.t.style.top="50%";

Hello,

I would like centering a form in a dhtmlxwindow and I’ve tested the code above.

I’ve the following JS error :

What is t ?

Thanks for any answer,

@++
JC

Any help would be appreciated

Thanks in advance

Unfortunately we cannot reproduce this issue locally. Can you please provide complete demo where we can reproduce it? You can find tutorial how to create complete demo here docs.dhtmlx.com/doku.php?id=othe … leted_demo

With dhtmlx 4.2 the following code seems to work

[code]var form = dhxLayout.cells(id).attachForm(…);

form.base[0].style.position=“absolute”;
form.base[0].style.width=“auto”;
form.base[0].style.marginLeft=-Math.round(form.t.offsetWidth/2)+“px”;
form.base[0].style.marginTop=-Math.round(form.t.offsetHeight/2)+“px”;
form.base[0].style.left=“50%”;
form.base[0].style.top=“50%”;[/code]