Start Building Professional
Web Apps Today


 
Categories Question details Back To List
Question  posted by Alex Thirlwall on Sep 24, 2008 01:44
open dhtmlx forum
dhtmlxtree resize

Hello there !
I would like to add whitespace to the bottom of a dhtmlxtree. At constructor time, if I set the height of the dhtmlxtree to more than what is required, then I get the desired effect. What I need is to be able to add items to the tree dynamically, obtain the new height, then increase it slightly so I have the whitespace after it. Here's a bit of pseudocode:

tree = new dhtmlXTreeObject(document.getElementById('archivetree'),"200","0",0);
tree.insertNewChild(0,1,"Item1",displayItem,0,0,0,"SELECT");
tree.setItemStyle(1," font: 11px Tahoma, Arial;");
tree.setItemImage(1,'drawer_closed.gif');
tree.insertNewChild(0,2,"Item2",displayItem,0,0,0,"SELECT");
tree.setItemStyle(2," font: 11px Tahoma, Arial;");
tree.setItemImage(2,'drawer_closed.gif');

// Here I want code to obtain the new height of the tree
// And here I want to add 20px to the height
// And here I want to set the extended height of tree so it displays with whitespace at the bottom !

I hope this is enough information.
Alex
Answer posted by dhtmlx support on Sep 24, 2008 07:05
You can try to call the following function when a new row is added:

function correct(){
    window.setTimeout(function(){
        var cont=document.getElementById("archivetree");
        cont.style.height=cont.firstChild.firstChild.scrollHeight + "px";
        cont.firstChild.style.overflow="hidden";
    },1)    
}