Start Building Professional
Web Apps Today


 
Categories Question details Back To List
Question  posted by Frank S. Waaland on Apr 24, 2009 01:42
open dhtmlx forum
treegrid center and set distance from top

We are using DhtmlxWindows together with DhtmlTreeGrid. The whole page is centered in the browser, and we would like to center the windows on page but want to set the distance in pixels from top where the windows will appear.

Today we use a <div id="..." Style...> to set a viewport, but the the window disapear when moving. We would liek to open several windows and move the beside eachother.

What we want to know is:

IS there a way to use default viewport settings (all of the browser area) and center the windows horizontal and set number of pixels from top.
Answer posted by Alex (support) on Apr 25, 2009 05:48

Hello,

You can try to use both center() and setPosition(x,y) methods. center() can be applied for centering horizontally, setPosition to set vertical position:

win.center();
win.setPosition(null,vertical_offset);

Please, use attached dhtmlxwindows.js. We've made some modifications in it to make the described approach possible.



Attachments (1)
Answer posted on Apr 26, 2009 22:52

I`ve just replaced the file and added the code, but it doesn`t seem to work for me, here is a snippet of the <script>

Mabye, I`ve done something wrong here

var dhxWins = new dhtmlXWindows();
        dhxWins.enableAutoViewport(false);
        dhxWins.attachViewportTo("window_containe");
        dhxWins.setImagePath("dhtmlsuite/dhtmlxWindows/codebase/imgs/");
        dhxWins.setEffect("move", true);
        dhxWins.setEffect("resize", true);   
 var w1 = dhxWins.createWindow("w1", 380, 100, 950, 520);
        w1.setText("Details");
        w1.button("close").enable();
        w1.keepInViewport(true);
        w1.center();
        w1.setPosition(null,100);

        dhxWins.window("w1").setModal(false);
        dhxWins.window("w1").bringToTop();

        dhxWins.window("w1").attachURL("details.php?id="+rowID.substr(1));
        dhxWins.attachEvent("onFocus", function(w) {
        dhxWins.window("w1").bringToTop();
 });
 
        dhxWins.window("w1").attachEvent("onClose", function() {

        dhxWins.window("w1").hide();
        mygrid.updateFromXML('data.php');
     });