drakkan
May 22nd, 2008, 08:54 PM
Hi,
I have a database with the following structure:
id name sublevel
for example
1 Node1 None
2 Node2 1
3 Node3 2
4 Node4 None
5 Node5 1
6 Node6 5
....
....
where Node1 and Node4 are treeview's master nodes, Node2 is a subnode of Node1, Node3 is a subnode of Node2, Node5 is a subnode of Node1 and Node6 a subnode of Node5 and so on
I need a recursive function to populate treeview and I'm stuck on this function :confused:
I need a list where I have the master node with child node inside and if a child node as others child nodes, I need thess nodes inside the child nodes.
Something like this:
[
{"id":1,"Childs":[{"id:2","Childs":[{"id":3,"Childs":[]}]},
{"id":5, "Childs":[{"id":6,"Childs":[]}]}]},{"id":4,"Childs":[]}
]
any help is appreciated,
thanks drakkan
I have a database with the following structure:
id name sublevel
for example
1 Node1 None
2 Node2 1
3 Node3 2
4 Node4 None
5 Node5 1
6 Node6 5
....
....
where Node1 and Node4 are treeview's master nodes, Node2 is a subnode of Node1, Node3 is a subnode of Node2, Node5 is a subnode of Node1 and Node6 a subnode of Node5 and so on
I need a recursive function to populate treeview and I'm stuck on this function :confused:
I need a list where I have the master node with child node inside and if a child node as others child nodes, I need thess nodes inside the child nodes.
Something like this:
[
{"id":1,"Childs":[{"id:2","Childs":[{"id":3,"Childs":[]}]},
{"id":5, "Childs":[{"id":6,"Childs":[]}]}]},{"id":4,"Childs":[]}
]
any help is appreciated,
thanks drakkan