ludo / jquery-treetable

jQuery plugin to show a tree structure in a table
http://ludo.cubicphuse.nl/jquery-treetable
GNU General Public License v2.0
741 stars 278 forks source link

Help with this one...for loops and loadBranching error #159

Closed Rocketboy123 closed 8 years ago

Rocketboy123 commented 9 years ago

Hello everyone,

I want to make this short and sweet. I have a list of nodes: {name: 'node 1', child: [{name: 'node 1.1', child:[{name: 'node 1.1.1'}]}, {name: node 1.2} ]}, {name: 'node 3', child:[{name: 'node 3.1'}, {name: '3.2'}]}, {name: 'node 2', child:[] }. That's my list. If there is an error in there, it's probably because I didn't write it correctly according to my memory. Hope you get the idea.

$("#treetable_1").treetable({ expandable: true }); I then do these for loops: for(int i = 0; i < list.length; i++){ var node = $("#treetable_1").treetable("node", i+1); $("#treetable_1").treetable("loadBranch",node, ""+ ""+list[i].name+ "");

for(int j = 0; j < list[i].child.length; j++){ var node = $("#treetable_1").treetable("node", i+1); if(!list[i].child[j].child.length){ $("#treetable_1").treetable("loadBranch",node, "<tr data-tt-id="+(i+1)+"."+(j+1)+" data-tt-parent-id="+(i+1)+">"+ ""+list[i].child[j].name+ ""); } else { $("#treetable_1").treetable("loadBranch",node, "<tr data-tt-branch=\"true\" data-tt-id="+(i+1)+"."+(j+1)+" data-tt-parent-id="+(i+1)+">"+ ""+list[i].child[j].name+ ""); }

for(int u = 0; u < list[i].child[j].child.length; u++){ $("#treetable_1").treetable("loadBranch",node, "<tr data-tt-id="+(i+1)+"."+(j+1)+"."+(u+1)+" data-tt-parent-id="+(i+1)+"."+(j+1)+">"+ ""+list[i].child[j].child[u].name+ ""); } } $("#treetable_1").treetable("collapseAll"); //this one doesn't work... }

source_code

Overall my result was this: Node 1 -Node 1.1 --Node 1.1.1 -Node 1.2

And nothing else. I don't get Node 3 and its children nor Node 2. Can you help me on this?

UPDATE: I noticed that my html tags aren't showing up. I hope you guys can see them though. If not, i don't know why they're not showing up.