I would like to get the sort order of the DBTreeView bean. Ccan I access that sort order somehow? The reason is I would like to display the rows in table view in the same order as displayed in the tree.
Is someone using a SQL statement to accomplish that and willing to share?
the sort order of the ‘Main nodes’ is just the sort order of those records in the foundset.
The sort order of the subnodes is basically determined by the ‘sort’ dataprovider.
If you don’t use the child’s sort dataprovider, I’d recommend you do so and you will know exactly what your sortorder should be…
_sort_order is a calculation with the content ‘name asc’, so doesn’t help at all.
But I would like to get the current sort order used in the DBTreeView, so I need a method like elements.dbTreeView.getChildSortOrder() giving me an array of the sort order of the DBTreeView bean.
Regards, Robert
mboegem:
Hi Robert,
the sort order of the ‘Main nodes’ is just the sort order of those records in the foundset.
The sort order of the subnodes is basically determined by the ‘sort’ dataprovider.
If you don’t use the child’s sort dataprovider, I’d recommend you do so and you will know exactly what your sortorder should be…
but what the sort dataprovider is returning for a specific node, is actually the children’s sort order
the dbtreeview does not sort anything if it is not set by the user, this is why I don’t understand what sort
string do you want to request from the bean
Robert Huber:
That’s no help, as it is always ’ name asc’ in my case, it’s a calc.
Or did I missunderstand you?
So your child records are sorted by name… then you can do a query (probably union select) on this table which:
a) finds all your parent nodes
b) finds all your child nodes
both based on the pk’s of the foundset of the form on which the DBtreeview is based
your a & b sql should return 1 column which holds the pk, the second column which holds the pk for part a, the parent_id + name column(in 1 column) for part b
This will result in a dataset, which you can sort on col 2.
Then load this onto the form you want to have the dataset on…
The sql would be something like this:
select k_pk_id, k_pk_id from dbtreeview_table where ........
union
select k_pk_id, k_parent_id_parent + name from dbtreeview_table where ........
I tried your SQL stmt but I am stuck (may be at the where clause, I’m not sure).
The table content (reduced to the important columns) looks like this. The table name is school_units. The id column is the pk, the school_unit_id is the foreign key (pointing to the parent node) and name is the column I’d like to sort - under consideration of the tree structure of course. id = 1 is the root of the tree, the entries with school_unit_id = 1 are nodes and the ones with 3 or 5 are the leafes.