Treeview : Relation on single table.

Hi All,

I’ve used the treeview bean before and have had relations from one table to another, but now I can’t get my head around how I would base it on a single table. Best way to explain would be to tell you guys my scenario:
I have navigation table which is based on levels ids and mother ids. so for example :

mother id1–|
'----child 1
'----child 2
'------------child 2a
'------------child 2b
'----child 2c
'------------child 2ca
'------------child 2ca
'----child 3
mother id2–|
'----child 1
'----child 2
'------------child 2a
'------------child 2b
'----child 2c
'------------child 2ca
'------------child 2ca
'----child 3

The structure will eventually go very deep so many childs under childs etc.
All the data are held in a single table called navigation with mother ids and level ids.
What’s the best way of implementing this in the treeview bean?
I tried to have a global selected Id and create the child nodes on selection, but I couldn’t get it to work, and Im not sure if this is th ebest approach as it will not
show the [+] idicator at the start to idicate that there are children for a particular mother id.
Should I be using the treeview at all for this or is there a way of easily implementing this using the treeview that I have missed out on?

Thanks in advance,

So the mother_id from child2a is the id from child2, right?
Then you should just create a relation from the id to the mother_id and use that in the tree.

Thanks for the reply Joas, yer I already have this relation. how would I bind this to the treeview, given that child 2a can have another child of its own child 2aa.
how would I initially bind each child to its mother, bottom up or top down, via a single relation? :? If I am making sense.

Yes, you just need the single relation.
The relation should go from table.id to table.mother_id.
Creating the binding should look like this:

var companies_binding = elements.tree.createBinding('example_data', 'companies');
companies_binding.setNRelationName('companies_to_companies');

Simple solution, I wish I had seen that before! thanks a lot! :D