3.5.4 DBTreeView bean: how to use the new functionality

The ability for a parent node to have child nodes over two different relations is something we are looking into for 4.0.

Paul

I discovered that
.setMethodToCallOnCheckBoxChange(BEAN_setCallBack, “show_chk”)
returns the dataprovider value and the tablename, but I can’t figure out what record is changed.
.getSelectedRecord() doesn’t work when editing a checkbox in the tree.
Suggestions are more then welcome! :wink:

instead of sending “show_chk” back, send the PK of the record back.

Paul

pbakker:
instead of sending “show_chk” back, send the PK of the record back.

Paul

Works perfectly, Paul! Thanks!

why is this bean getting its data from dataproviders instead of getting it it direct either from a string of fieldname?
this requires to create as many fields as parameters required, and sometimes these fields are just return 0 ;’ a bit of a waste…
also, apart from this example, no serious doc has been found… or its location is not obvious enough? such an important feature requires a detailed doc per command, etc… working out my way from examples is time consuming…

There are allready several post on this forum about the documentation of this bean.

With regards to the fact why fields are used: Because that allows you to use calculations, which in turn make each node customizable. That wouldn’t be possible just using a text string.

Paul

fields: I understand, but using field content or “strings” directly look easier: if half of the things you wanna use are static, then you have to create calc. fields for nothing when they are static data. does it simplify the work on your side at least?
doc: the usual debate… I know compiling documentation looks a waste of time for a software editor, but my point of view is a bit different: nowadays, learning an app means spending a lot of time to collect bits and pieces from here and there. If you would have inserted this in the ref manual (it deserves it, the dbtree is an interesting feature), you would not have to waste your time to answer all those questions on the forum, and I would have found what I am looking for in seconds. The post here show examples, but I have to work out the explanations from that, no real “teaching”. If if I can find some time in the next 2 weeks (can’t promise that now), I’ll write the topic I would have like to find on the subject, once I’ll master the beast myself (not done yet) and send it to you. Getting this tool on the web client is absolutely great (only flash can do this via an intermediate xml file, and php with 500 lines of code), I am sure not even 20% of servoyians are using it because the doc ref is missing and its usage is somehow not easy enough. Anyway, thanks for answering, Servoy is responsive, and I do appreciate that.

[Servoy 3.5.6]

I’ll share a little bit of code, in case this helps someone else move ahead with the DBTreeView bean. This bean reads 3 levels deep, finding related records from 3 separate, but related tables:

Tables:
Clients
Projects (clients_to_projects)
Tasks (projects_to_tasks)

Place the DBTreeView bean on your form and note the name.

form onLoad method:

var tree_clients = elements.bean_859.createBinding('my_data', 'clients')
var tree_projects = elements.bean_859.createBinding('my_data', 'projects')
var tree_tasks = elements.bean_859.createBinding('my_data', 'tasks')

tree_clients.setNRelationName('clients_to_projects')
tree_projects.setNRelationName('projects_to_tasks')
tree_projects.setNRelationDataprovider('clients_to_projects')
tree_tasks.setNRelationDataprovider('projects_to_tasks')
tree_clients.setTextDataprovider('company') // company is a field in the clients table
tree_projects.setTextDataprovider('project_name') // project_name is a field in the projects table
tree_tasks.setTextDataprovider('task') // task is a field in the tasks table

var fs = databaseManager.getFoundSet('my_data', 'clients')
fs.find()
fs.search(true, true)
elements.bean_859.addRoots(fs);

Nothing fancy, but it gets you started with a working, multi-level tree.

I underwrite all this that has said Lesouef. The bean dbtree it is a too much important functionality for the insufficient documentation of like is used. The potentialities in industrial field with components of production and working cycles are remarkable.

I did 2 sessions at ServoyWorld 2008 on the DBTreeView bean. You can download the slides here.

Hope this helps.

Hello,

This is a very cool bean, but I am struggling a bit with populating child nodes. Your example is clear enough, but I want to fill root nodes and child nodes from queries, not from Servoy relationships, and I don’t necessarily need the data “binding” to update automagically/broadcast changes. Is there no way to recursively set child nodes with a query? Do I have to go the binding route and tie roots to children using Servoy relationships?

Thanks for putting this together.

Hi Jeff,

The bean needs the binding objects and these needs relationships. What you can do however is using globals in your relationships to filter your child nodes.
A relationship with a global on the left side is in essence a (related) foundset with a WHERE clause.

Hope this helps.

Jeff, you could test drive our treeview bean but it is not yet really ready.
It even allows you to add ‘manually created’ records…

thanks roclasi for the doc, it confirms what I knew by now.
could it be more accurate about the sort order: I still have this problem and could not get any answer yet: whatever I do, it does not use the sort field string to sort; is it really the usual sort syntax?
ex: I am using in the calc. sort field:
return ‘[myfieldname] desc’ ;
but it stays ascending for instance…
and none of the examples I found is using this sort field…
has anyone been able to use it successfully?

If I’m correct level zero order is taken from the foundset you use to populate the bean, the other levels use the calculation text.
Try to sort your foundset before initing the bean and see what happens.

sorting the foundset is OK for the root level, I agree, but my problem is to sort children…

For the children the sort field is used. Can you show us some code, sorting is working fine for me so it must be something in the code you use.

sure, here is the code setting up the bean:

elements.bean_nav.removeAllRoots();

$binding = elements.bean_nav.createBinding(controller.getServerName(),‘products’);
$binding.setImageURLDataprovider(“bean_image”);
$binding.setChildSortDataprovider(“bean_sort”);
$binding.setHasCheckBoxDataprovider(“bean_checkbox”);
$binding.setCheckBoxValueDataprovider(“”);
$binding.setNRelationName(“products_to_components”);
$binding.setTextDataprovider(“bean_txt”);

$binding = elements.bean_nav.createBinding(controller.getServerName(),‘components’);
$binding.setImageURLDataprovider(“bean_image”);
$binding.setChildSortDataprovider(“bean_sort”);
$binding.setHasCheckBoxDataprovider(“bean_checkbox”);
$binding.setCheckBoxValueDataprovider(“”);
$binding.setTextDataprovider(“bean_txt”);

$binding.setMethodToCallOnClick(show_record, ‘cp_jobid’);
elements.bean_nav.addRoots(forms.products_filter.foundset); //product level
elements.bean_nav.visible = true ;

This bean is just awesome! Thanks for the examples and explanations, Paul - really helpful stuff.

2 questions come to mind:

  • I see an ‘MRelationName’ and ‘MRelationDataprovider’ - how do these differ form ‘NRelationName’ and ‘NRelationDataprovider’?
  • Is there a way to make non-editable the checkbox obtained by ‘setCheckBoxValueDataprovider’ and ‘setHasCheckBoxDataprovider’?

Thanks in advance,

Ben

Hi Ben,

LOGIsoft:

  • I see an ‘MRelationName’ and ‘MRelationDataprovider’ - how do these differ form ‘NRelationName’ and ‘NRelationDataprovider’?

See my slides at viewtopic.php?f=27&t=11129
You only use MRelationName/Provider in specific n:m relationships…which are probable kinda rare (see page 28 of the DBTreeViewIntro slides).

LOGIsoft:

  • Is there a way to make non-editable the checkbox obtained by ‘setCheckBoxValueDataprovider’ and ‘setHasCheckBoxDataprovider’?

Good question! Not via the normal methods/properties so I suggest you file it as a feature request.

Hope this helps.