Does anyone know of a plugin or code snippet that will take results from a database and create a properly nested unordered list so that I can use it with jQuery OrgChart(
https://github.com/wesnolte/jOrgChart#readme).I have data that might be as many as 14 levels deep that needs to be displayed in a tree-like fashion. The single largest problem that I have is that I must recursively search each item for dependents and add them to the tree. I have been working on it for a couple of days and it seems that I cannot get the nested unordered lists closed properly. The OrgChart plugin works great and is easy to customize for look and feel - I just need to crack the underlying logic.
I have shortened the tree to a three level tree to see where I might be going wrong, but to no avail. I am just missing the logic on how to close each <ul>. from the routine that gets the data. Here is how the current logic works - (pseudo-code)
while(level1) {
if(thisLevel1Item has children) {
echo <li>thisLevel1Item
echo <ul>
} else {
echo <li>thisLevel1Item
}
while(level2 is related to thisLevel1Item) {
....etc