setChildSortDataprovider() in DBTreeViewBean does not work

Hello,

the method setChildSortDataprovider([dataprovider]) of the DBTreeViewBean (in Servoy 4.1) seems not to work. After changing the value of the dataprovider and a refresh of the DBTreeViewBean or changing the record and going back to the first chosen record does not change anything.
Here is the code:

vTreeBean = elements.tree_bean.createBinding(controller.getServerName(), controller.getTableName());
vTreeBean.setChildSortDataprovider('bausteine_position');
vTreeBean.setNRelationName('bausteine_zuordnungen__uid_bausteine_to_bausteine_zuordnungen__uid_bausteine_parent');
vTreeBean.setTextDataprovider('bausteine_typ');
vTreeBean.setMethodToCallOnClick(tree_bausteinAufrufen, 'uid_bausteine_zuordnungen');

Is this a bug in the DBTreeViewBean or in my code?

Thank you!

Greetings
Christoph

hi Christoph,

Christoph:
Is this a bug in the DBTreeViewBean or in my code?

sorry to tell you… it’s your code :wink:

I made the same mistake when I first used the DBTreeViewBean.
What you actually should use is a dataprovider that returns a string like ‘bausteine_position asc’;

so use:

_treeBind.setChildSortDataprovider('c_child_sort');

where ‘c_child_sort’ is like:

function c_child_sort()
{
	return 'bausteine_position asc';
}

The idea behind this that you could - based on severa criterea - use different sort fields or change the asc/desc…

Hope this helps!

Hi Marc,

thanks for your reply.
But unfortunately it does not work in Servoy 3.5.7 and Servoy 4.1.

@Servoy: Could you please verify if there is a bug in the bean?

Thank you!

Christoph

It works fine for me, Marc is correct, keep in mind that to order the root level of your tree you simply need to sort the foundset used to build it and to sort the childs you need to create a calculation that returns the sorting string as Marc pointed out.

Hi Nicola, thnkx for your completion… forgot to mention the root levelsort.

@Christoph: we have working examples in both versions but as the name ‘setChildSortDataprovider’ explains, this will take care of the sortorder of the child, grandchild, etc. records.

Hi,

thanks for your posts.
I now found the bug. If the relation I use in setNRelationName() contains more than 1 condition (from table, operator, to table) the DBTreeViewBean wil not sort their child records any more.

Would be nice to be fixed soon.

Thanks.
Christoph

Hi Christoph,

Christoph:
Would be nice to be fixed soon.

Did you file it yet in the Servoy support system ?

hi to all,

the bug has been fixed in the upcoming relase

regards,
Gabi

hi,

was this issue ever fixed? Or could someone tell me what I may be tdoing wrong here?

I have tried the suggestions in the forum and am unable to get the list to sort properly

var binding = elements.beanTree.createBinding(‘database’, ‘parentType_table’)
binding.setNRelationName(‘parentTypeTable_to_childTable’)
binding.setTextDataprovider(‘name’) // company is a field in the clients table
binding.setChildSortDataprovider(‘name_sortAsc’);

binding= elements.beanTree.createBinding(‘database’, ‘childTable’)
binding.setNRelationName(‘childContained_to_childContaining’) //recursive table related to itself
binding.setTextDataprovider(‘contained_name_sortAsc’)

  1. added foundset initial sort to sort the parent nodes
  2. added calcs into “parent” and “child” tables
  • tried setting the sort to the parent table calc and the child table calc, but the sorting doesn’t work. The only place I can get sorting to work is on the foundset initial sort.

Thanks

Look at viewtopic.php?f=15&t=15516&hilit=setChildSortDataprovider .

Be aware each createBinding requires a different variable (in your example you are using variable binding for both createBinding)