dhtmlx tree height resize

Hello,



is it possible that the tree is resized dynamically, so that the scrollbar is never shown.



I want the tree to use as little vertical space as possible, but when a tree item is opened and subitems are shown, I want the tree height to expand so that the scrollbar is never shown.



It that possible?



Thanks in advance!

There is no native support for such functionality, but you can use some custom code attached to onOpenEnd event similar to next

tree.attachEvent(“onOpenEnd”,function(){
var h = this.allTree.scrollHeight;
document.getElementById(“treebox”).style.height=h+“px”; //set size of tree’s container
return true;
});


Thanks for
the answer. That works nice. But is there also a way to automatically decrease
the height when I collapse some three items?<o:p></o:p>

I figured out a sollution. In the onOpenEnd function, I first set the height to 1px. That works perfect!

tree.attachEvent(“onOpenEnd”,function(){
   document.getElementById(“treebox”).style.height=“1px”; 
   var h = this.allTree.scrollHeight;
   document.getElementById(“treebox”).style.height=h+“px”; //set size of tree’s container
   return true;
});