Start Building Professional
Web Apps Today


 
Categories Question details Back To List
Question  posted by Bill Parker on Mar 18, 2009 10:48
open dhtmlx forum
Grid window resize

I have aet up a simple grid in a DIV set to Width="100%" Height="100%" - which is supplied with XML by an .asp script, pretty much in line with you /asp server side example - the problem is that the div wwill auto resize to the height of the window, but the width just gradually SHRINKS if I resize the browser in any way, an there is always a horizontal scroll bar visible..

If I leave the mygrid.setInitWidths setting out the grid is incomplete, single wide column, but it does resize in both dimensions as expected..

Please help

Script is below

<html>
<head>
<link rel="STYLESHEET" type="text/css" href="codebase/dhtmlxgrid.css">
<script src="codebase/dhtmlxcommon.js"></script>
<script src="codebase/dhtmlxgrid.js"></script>
<script src="codebase/dhtmlxgridcell.js"></script>
<script src="codebase/ext/dhtmlxgrid_srnd.js"></script>
<script>
var gridQString = "ASPTable.asp";
</script>
<head>

<body topmargin="0" leftmargin="0" rightmargin="0">
<div id="products_grid" style="width:100%;height:100%;"></div>

<script>

var mygrid = new dhtmlXGridObject('products_grid');
mygrid.enableAutoHeight(true,"auto");
mygrid.enableAutoWidth(true,"auto");
mygrid.setSizes();
mygrid.setImagePath("codebase/imgs/");
mygrid.setHeader("Doc,Rev,Originator");
mygrid.setInitWidths("100,*,100");
mygrid.setColAlign("left,left,left");
mygrid.setSkin("modern");
mygrid.loadXML(gridQString );
mygrid.enableSmartRendering(true);

mygrid.init();

dhtmlxEvent(window,"resize",function(){mygrid.setSizes();});

</script>

</body>
</html>

Answer posted by dhxSupport on Mar 19, 2009 03:37

If you want grid columns change it's size depend on the window resize you should set it's width in percents. You can do it with setInitWidthsP method:

var mygrid = new dhtmlXGridObject('products_grid'); 
mygrid.setImagePath("../codebase/imgs/"); 
mygrid.setHeader("Doc,Rev,Originator"); 
mygrid.setInitWidthsP("50,10,40"); 
mygrid.setColAlign("left,left,left"); 
mygrid.setSkin("modern"); 
mygrid.enableSmartRendering(true); 
mygrid.enableAutoHeight(true); 
mygrid.init(); 
mygrid.loadXML(gridQString);