Re: How do I make a HTML tree for a set of nodes?

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hi,

On Sunday 04 June 2006 19:08, tedd wrote:

> At 3:38 PM +0200 6/4/06, Niels wrote:
>>On Sunday 04 June 2006 15:30, tedd wrote:
>>
>>[snip]
>>
>>> You can dynamically generate a table and place text (and/or color) the
>>> cells that are nodes -- that would be my approach. You would need to
>>> know the width and depth of the tree and then just fill in the cells
>>> that are nodes.
>>>
>>> hth's
>>>
>>> tedd
>>
>>Yes, well... It's a tad more complicated I think. Yes, I can make a table,
>>finding the dimensions shouldn't be a big problem. Placing the nodes in
>>the right cells isn't as easy, and making the connections is downright
>>difficult.
>>
>>A problem with using a table is that cells can't be individually sized.
>>However DIVs or TDs is a minor problem. The major problem is to walk
>>through the tree properly (recursively probably), and remember the
>>connections. And then rendering them...
> 
> I've done this before, but not with html.
> 
> My demo is at:
> 
> http://www.sperling.com/freeware.php
> 
> So, I have an idea of what's involved.
> 
> If this just for display, then it shouldn't be too difficult to display
> the end results in a table -- provided, you know in advance the largest
> any row will be. It will be a simple grid, unless you want to play with
> column spacing, which will be very difficult indeed to manage.
> 
> As for cells not being individually sized, you're right they can't be
> sized, but they do automatically size to their contents and that can be
> varied as well shown with different background colors.
> 
> Are you going to use this for something other than display, is it
> functional in some way? Because if you're going to add functionality, such
> as editing, deleting, sorting, then you have a big chore in front of you.
> 
> As for using recursive functions, absolutely -- they make the process (and
> code) much less. However, you need to wrap your mind around things
> spinning around to their conclusion, which is sometimes difficult to
> imagine.
> 
> Good luck.
> 
> tedd

Thank you for your answer, I appreciate it!

Years ago I made Javascript navigation tree -- like a file browser, with
expandable branches and so on. It was a big problem to parse all the
relationships to img tags and links. I just had a looks at that code -- 10
years old, and it works! I couldn't change it to my current needs though.

As I said elsewhere on this thread, I've settled for a simple, indented
tree-view. Each node is a link and some text, and it's all reasonably easy
to understand. And it's a small function -- I know about the dangers of
recursion.

Choosing this simple layout will also make it easier to render the output to
PDF at a later stage.

If I were to make a "real" tree, I wouldn't use a table. It's too difficult
to manage IMO. I'd probably look for a generic graph algorithm somewhere,
and try some dhtml voodoo with flying DIVs.


Thanks again,
Niels

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux