I have a db table (category) with the following structure:
category_id (primary key)
description
parent_id
I have added a relation category$parent_to_child and I can use the following code to create a hierarchical tree using the DBTreeView bean no problem and everything works as expected:
- Code: Select all
var _first_binding = elements.category_tree.createBinding(foundset.getDataSource());
/*
* Set the calculation that returns the icon name, the sort order for the nodes, the relation for the child nodes
* and the field to be used for the node text
*/
_first_binding.setImageURLDataprovider('display_icon');
_first_binding.setChildSortDataprovider('tree_sort');
_first_binding.setNRelationName('category$parent_to_child');
_first_binding.setTextDataprovider('description')
Now I also have a second table (product) with the structure;
product_id (primary key)
category id
item_name
I want to add this into the DBTreeView and show each product in the tree under its relevant category. I have added the relation category_to_product using the category_id and want to add this to the tree but nothing I try seems to work. I have tried using:
- Code: Select all
_first_binding.setMRelationName('category_to_product');
and also
- Code: Select all
var _second_binding = elements.category_tree.createBinding(forms.categories.controller.getDataSource());
_second_binding.setNRelationName('category_to_product');
_second_binding.setTextDataprovider('item_name')
but neither give the result I want.
Can anyone give me some pointers on how to achieve this please?
Thanks
Steve