The dhtmlxObject's container(The div) can be autosize?

The dhtmlxGrid or dhtmlxTree are created in a div.At first,we should give the div width and height,which always make the scrollbar visible.

I want to know.Is there any way to make the div be autosize(based on the data rows) ,so the scrollbar is not visible.

You can enable auto-height of grid, in such mode, height of grid container will be encreased automatically , according to used rows.

grid.enableAutoHeight(true);


when i use  it, web page is erro , ie give a erro,which is no such property . I use dhtmlxtreegrid



grid.enableAutoHeight(true);

Which version of component you are using?
The command exists in both dhtmlxgrid and dhtmlxtreegrid starting from version 1.4


I use 1.5 version.the keyword “enableAutoHeight” is searched in dhtmlxgrid.js.

The order of  js's introduction will be impact it? or the  enableAutoHeight's call time is erro?
 
 
-----------------------------

 
script  src="../js/dhtmlobj/dhtmltreegrid/js/dhtmlXGrid.js">
 



 
  mygrid = new dhtmlXGridObject('gridbox');
  mygrid.selMultiRows = true;
  
  mygrid.imgURL = "../js/dhtmlobj/dhtmltreegrid/imgs/";
  mygrid.setHeader("xx,yy,zz");
  mygrid.setInitWidths("260,50,50")
  mygrid.setColAlign("left,center,center")
  mygrid.setColTypes("tree,ro,ro");
  mygrid.setColSorting("str,str,str")
  mygrid.setColumnColor("white,#def7ff,white");
  mygrid.enableAutoHeight(true,100,100);
  mygrid.init();
  mygrid.enableSmartXMLParsing(true);  
  mygrid.kidsXmlFile="../servlet/CkServlet";
  var v_url="xxxxxxx";
  mygrid.loadXML(v_url);

 
script  src="../js/dhtmlobj/dhtmltreegrid/js/dhtmlXGrid.js">
 



 
  mygrid = new dhtmlXGridObject('gridbox');
  mygrid.selMultiRows = true;
  
  mygrid.imgURL = "../js/dhtmlobj/dhtmltreegrid/imgs/";
  mygrid.setHeader("xx,yy,zz");
  mygrid.setInitWidths("260,50,50")
  mygrid.setColAlign("left,center,center")
  mygrid.setColTypes("tree,ro,ro");
  mygrid.setColSorting("str,str,str")
  mygrid.setColumnColor("white,#def7ff,white");
  mygrid.enableAutoHeight(true);
  mygrid.init();
  mygrid.enableSmartXMLParsing(true);  
  mygrid.kidsXmlFile="../servlet/CkServlet";
  var v_url="xxxxxxx";
  mygrid.loadXML(v_url);

The order of js files and time of command call doesn’t matter ( basically command need to be called before loading data in grid, but it not really critical )
Sample of same functionality with grid 1.5 sent by email

By the way, your code snippet missing dhtmlxcommon.js , without which grid will not work at all.

thank you very much.


thak you!  now  The “enableAutoHeight” is working.



but there is a strange thing has happened. In the page ,I have a dhtmlxcombo and a dhtmlxtreegrid.when the treegrid is enableAutoHeight, the dhtmlxcombo’s position is very strange, It

Deviate its location 50~100 px

If you have combo opened, and expand the grid after that - such behavior can really occur.
The position of combo list is fixed , and not changed when surrounding layout shifted.

You can try to add next code to grid’s init
grid.attachEvent(“onOpen”,function(){
combo.closeAll();
return true;
));