Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > ASP General > Displaying Preorder Tree Traversal Hierarchy in ASP?

Reply
Thread Tools

Displaying Preorder Tree Traversal Hierarchy in ASP?

 
 
FrankEBailey
Guest
Posts: n/a
 
      02-13-2006
I've been reading up on Modified Preorder Tree Traversal and it's
definitely ideal for the kind of tree structures I need to model for my
company's multi-level sales hierarchy. I've implemented the database
side already in SQL Server 2000 and can retrieve all child nodes based
on the left and right IDs of the current node. My problem is displaying
the tree so that correct indentation can be used to show the
relationships between the parents and their respective child nodes.

I'm aiming for this type of display:

Organic_Produce
- Fruit
- Banana
- Cherry
- Orange
- Vegetables
- Potatoes
- Savoury Potatoes
- Sweet Potatoes
- Zucchini

etc.

Now, I know a recursive function of some sort is needed, and I read on
this page http://www.sitepoint.com/print/hiera...-data-database how
to create the function in PHP, however I don't have the first clue how
to translate this into VBScript for implementation in ASP. If anyone
has perhaps an example of how a function to display MPTT-type
hierarchical data via VBScript, I will greatly appreciate any
assistance you might be able to offer.

Thanks in advance!
Frank

 
Reply With Quote
 
 
 
 
FrankEBailey
Guest
Posts: n/a
 
      02-14-2006
Can anyone help me on this?

 
Reply With Quote
 
 
 
 
Anthony Jones
Guest
Posts: n/a
 
      02-18-2006
>I've been reading up on Modified Preorder Tree Traversal and it's
>definitely ideal for the kind of tree structures

<snip>
>Now, I know a recursive function of some sort is needed


Actually I think the whole point of the left right values in this technique
is to avoid having recursive functions which can become very slow.

All you need is a single recordset ordered by Left. The code is something
like this:-

Dim lLastLeft
Dim lDepth
Dim alRight

lDepth = 0

lLastLeft = rs("left")

ReDim alRight(4)
alRight(lDepth) = rs("right")

RenderRecord rs, lDepth
rs.MoveNext

Do Until rs.EOF

Do Until alRight(lDepth) > rs("left")
lDepth = lDepth - 1
Loop

If lDepth = UBound(alDepth) Then ReDim Preserve alRight(lDepth * 2)
lDepth = lDepth + 1
alRight(lDepth) = rs("right")

RenderRecord rs, lDepth

rs.MoveNext
Loop

Anthony.


 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Windows 7 -on sale-preorder offer RoseW Windows 64bit 4 07-04-2009 01:30 PM
preorder canon 40d & 1ds mk iii at amazon nospam Digital Photography 6 08-20-2007 05:38 PM
Giving the preorder & inorder lists, How can be constructed the corresponding B-TREE ? David Méndez C++ 9 11-16-2004 09:40 AM
Giving the preorder & inorder lists, How can be constructed the corresponding B-TREE ? David Méndez C Programming 10 11-16-2004 09:40 AM
DDDVD - preorder vs. currently not in stock Video Flyer DVD Video 4 05-22-2004 03:53 PM



Advertisments