Logic for displaying infinite category tree in nested <ul>s from Self Join Table

Posted by Sundermagar under Regular Expressions on 2/17/2011 | Points: 10 | Views : 1664 | Status : [Member] | Replies : 1
Hi everybody!

Table "Menu"
MenuID | Description | ParentID
1 | Main Nav |
2 | Sub | 1
3 | sub sub | 2

and so on....

I DO NOT WANT TO USE TREEVIEW CONTROL OR Menu Control!!!

Please help me solve my big problem.
in my on-line shopping project i created a dynamic Category List (with Infinite Level Depth) Implemented in a Single Table in DB with Self join. the schema is like below:
alt text

Update
I want to use a JQuery plugin to make a Multi Level Menu bar. this plugin uses <ul> and <li> elements so I should transform the DB table to <ul> and <li>. the result should like this:

<ul>
<li>Clothing 1
<ul>
<li>Trousers 2
<ul>
<li>Mens trousers 3</li>
<li>Ladies trousers 3</li>
</ul>
</li>
<li>Jackets 2</li>
<li>Shirts 2</li>
<li>Shoes
<ul>
<li>Mens shoes 3
<ul>
<li>Mens formal shoes 4</li>
<li>Mens casual shoes 4</li>
</ul>
</li>
<li>Kids shoes 3</li>
<li>Ladies shoes 3</li>
</ul>
</li>
</ul>
</li>
<li>Cars 1
<ul>
<li>Small cars 2</i>
</ul>
</li>
</ul>

Sunder Magar


Responses

Posted by: Madhu.b.rokkam on: 2/17/2011 [Member] [MVP] Bronze | Points: 25

Up
0
Down
Any specific reason behind not using the Menu or tree view controls ??

Thanks and Regards
Madhu

Sundermagar, if this helps please login to Mark As Answer. | Alert Moderator

Login to post response