[thelist] Large expandable tree

Sam sam at sam-i-am.com
Thu Aug 28 09:08:02 CDT 2003

I was faced with exactly the same problem recently.
Ultimately we ended up making the tree entirley on the server-side. But 
I looked into some options like using some remote scripting to load tree 
nodes on demand (I would load the first level, and the immediate 
children. The onclick fired a function to load in the grandchildren in a 
hidden iframe and copy the relevant innerHTML over to the srcElement 
(rather than grabbing the nodes individually and formatting them I was 
able to reuse an existing template to get the markup I needed).

My prototype was looking good, but at the time the servlet relied on a 
one to one mapping of page to template so I couldn't generate the pared 
down navigation-only hidden content I needed.

Your success with this approach will depend on the nature of the tree - 
it works well for a deeply nested tree, but the perfomance gain is not 
so good for a large, shallow tree. It really helps if your markup comes 
through as nested elements to mirror the tree structure, rather than 
just ID-ing them or something and producing one big flat list of 
elements. Then you can leverage the built in DOM methods to manage the 

(this node tree business gives rise to the most contorted mixed 
metaphors dont you find?)

I'd be happy to compare notes.

Hershel Robinson wrote:

> Everything works well, but now our trees are growing larger and the time to
> build the tree is growing too large. This is not terribly surprising, given
> the nature of the code and how it processes the array. When we first built
> the page, I was not aware that our trees might grow so large. :)

More information about the thelist mailing list