Click to See Complete Forum and Search --> : displaying relationships


okrocker
03-14-2003, 10:45 AM
I've populated an array of parents & children. Some children are also in the parents column because they have children. I want to display their relationship like a family tree. The data in the array will be dynamic. Not sure how to go about this, help!
thanks,
archie

Vladdy
03-14-2003, 11:06 AM
Tree hierarchy and array are two different things. Do not confuse them.
If you have a tree structure with parent-child relationships, you can not effectively present them in an array. See my DOM Tree Viewer (http://www.vladdy.net/webdesign/DOM_TreeViewer.html) for a possible solution.

okrocker
03-14-2003, 11:21 AM
do you have an example of what your code does, how it looks real time? I suppect its alot more than I need & I'm like you I don't what to clutter up my pages with unnecessary code. I don't need to expand or colaspe anything. Just want to show the whole family with the current data. I might make them active links, not sure yet if thats needed.

Vladdy
03-14-2003, 11:41 AM
In the link I gave above click on DisplayDOM('content'). It will pop up a window with the collapsed tree of DOM objects. You can navigate it by expanding/collapsing different branches. For this particular application I found it to be a preferrable presentation method due to a sicnificant number of nodes.
If your number of nodes is limited and you want to present them all expanded, just go with nested lists.

okrocker
03-14-2003, 11:50 AM
Now you already know my next Q. Do you have any examples of nested list?
thanks again

Vladdy
03-14-2003, 01:58 PM
The actual implementation would depend on your data structure. As far as the code goes it is nothing more than dynamic creation of node tree representing your data tree using
with(document.createElement('ul'))
{ with(appendChild(document.createElement('li')))
{ appendChild(document.createTextNode(data));
}
}