DBTreeview effort

The following is my code for my attempt at getting the bean to work. It ain’t… I get the error “Foundset accessed while not initalised (possible in form.onload method)”

I do not know why it is not working. Ideas would be fantastic.

	var _binding = elements.dbtreeview2.createBinding(controller.getServerName(),controller.getTableName());	
	_binding.setNRelationName('category_to_category');	
	_binding.setTextDataprovider('category_name'); 
	
	controller.find();
	parent_id = 0;
	controller.search(true,true);
	elements.dbtreeview2.addRoots(foundset);

The category_to_category relation sources are category_id & parent_id.

Are you running this in your onLoad method? Because in that case the foundset isn’t available yet.
Try running it in the onShow method instead.

Note that the onShow method receives a boolean that indicates if it is running for the first time:

var _firstTime = arguments[0];

if (_firstTime) {
	//initialize tree
}

Joas, for the treeview bean this is not true.

the sample solution of the dbtreeview, also does everything in de onLoad!
We are using this also, AND touching the foundset (by doing controller.find() etc…) and it just works fine.

if we do it in the onShow, we first see the default values of the dbtreeview for 1 second, like: colors, sports, food etc…
and than the actuall values, which we find ugly!

Thanks Joas that worked.

How do I get the child records to show under the root nodes?

4xjbh:
How do I get the child records to show under the root nodes?

That should happen automatically if your binding is correct.

What does your “category_to_category”-relation look like?
Based on the code you posted I think it should be: ```
category.category_id = category.parent_id