Paul,
What you say makes sense and I suspect it’s the syntax of the method that is letting down my efforts.
So we all can relate to this topic, I have used your TreeBeanSample and added the following columns to the CRM database ‘Companies’ table:
division_id
subdivision_id
subdivparent_id.
I retained the ‘companies_to_companies’ relation which is company_id to parent_id (this gets the child nodes in the top left tree in the solution (company_tree).
I added the relation ‘companies_to_companies_divtosubdiv’ to create the child nodes from division to sub division. All aforementioned relations are within the companies table.
I then created the following unstored calc as you suggested, called ‘relation_name’:
if ( parent_id != null && subdivparent_id == null )
{
return ‘companies_to_companies’;
}
else if (parent_id != null && subdivparent_id != null)
{
return ‘companies_to_companies_divtosubdiv’;
}
I put some test data in and then tried many ways to try and get the nodes to render with no success. I have used the bottom left tree of your solution as the test and this is last variant of code I have tried in the ‘onLoad’ method:
//Init Multi Table Tree
_binding = elements.multiple_related_tables_tree.createBinding(controller.getServerName(), controller.getTableName());
_binding.setNRelationDataprovider(‘relation_name’);
_binding.setImageURLDataprovider(‘type_icon’);
_binding.setTextDataprovider(‘company_name’);
_binding = elements.multiple_related_tables_tree.createBinding(controller.getServerName(), controller.getTableName());
_binding.setNRelationDataprovider(‘relation_name’);
_binding.setImageURLDataprovider(‘type_icon’);
_binding.setTextDataprovider(‘company_name’);
controller.find();
parent_id = ‘^’;
subdivparent_id = ‘^’;
controller.search(true,true);
elements.multiple_related_tables_tree.addRoots(foundset);
This method gets the parents OK but renders no children (I gues you could say the tree is barren…
) The icons render OK, with different pretty colours for the different company_type_id.
The top left (company_tree) renders the division nodes, but that is it.
As a new Servoyian, I have to say that this TreeBean has proved harder to master than any of the J* beans I have tried so far (I guess the internet helps here) and all the SQL stuff. I hope your reply may help others with this bean!