Start Building Professional
Web Apps Today


 
Categories Question details Back To List
Question  posted by jos on Feb 06, 2009 02:11
open dhtmlx forum
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!
Answer posted by Support on Feb 06, 2009 04:54
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;
});
Answer posted by jos on Feb 06, 2009 05:47

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

Answer posted by Jos on Feb 06, 2009 05:54
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;
});