# DBtreeview multiple table tree not able to sort child nodes

**URL:** <https://forum.servoy.com/t/dbtreeview-multiple-table-tree-not-able-to-sort-child-nodes/13454>\
**Category:** Classic Servoy\
**Created:** [January 14, 2011, 7:26pm UTC](https://forum.servoy.com/t/dbtreeview-multiple-table-tree-not-able-to-sort-child-nodes/13454 "2011-01-14T19:26:32Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![nestrocuation](https://avatars.discourse-cdn.com/v4/letter/n/e19adc/32.png) [@nestrocuation](https://forum.servoy.com/u/nestrocuation)\
**Post date:** [January 14, 2011, 7:26pm UTC](https://forum.servoy.com/t/dbtreeview-multiple-table-tree-not-able-to-sort-child-nodes/13454/1 "2011-01-14T19:26:32Z")

</div>

Hello all ,

I searched whole forum for the documentation for a Dbtreeview and the one that i found was not that helpful .This is my code for the multi table tree .

This is my code for Tree

> var first\_bind = elements.bean\_rec\_nav.createBinding( \_SERVER, firstbinding);  
> first\_bind.setNRelationName(\_relation)  
> first\_bind.setChildSortDataprovider(first\_sort\_dp) // first\_sort\_dp-calculation which returns string (string : “second\_bind\_name asc”)  
> first\_bind.setTextDataprovider(\_dp)  
> first\_bind.setMethodToCallOnClick(callmethod,“\_id”)  
> var second\_bind = elements.bean\_rec\_nav.createBinding( \_SERVER, secondbinding);  
> second\_bind.setTextDataprovider(second\_dp);  
> second\_bind.setChildSortDataprovider(second\_sort\_dp)// second\_sort\_dp-calculation which returns string (string : “third\_bind\_name asc”)  
> second\_bind.setNRelationName(2\_relation);  
> second\_bind.setMethodToCallOnClick(callmethod,“\_id”)  
> var third\_bind = elements.bean\_rec\_nav.createBinding( \_SERVER, thirdbinding);  
> third\_bind.setNRelationDataprovider(2\_relation);  
> third\_bind.setTextDataprovider(third\_dp);  
> third\_bind.setMethodToCallOnClick(callmethod,“\_id”)
> 
> fs = databaseManager.getFoundSet( \_SERVER, thirdbinding)  
> fs.loadAllRecords();  
> fs.sort(relation.first\_bind\_name); //this sorts mother node  
> var rel\_fs = databaseManager.convertFoundSet(fs,fs\_relation);
> 
> elements.bean\_rec\_nav.removeAllRoots();  
> elements.bean\_rec\_nav.refresh();  
> elements.bean\_rec\_nav.addRoots(rel\_fs);

The tree is loaded just fine , and the sorting of the mother node is just fine as i am sorting it through the foundset , but seems like sorting of child node is not working , i dont know if there is something that i am doing wrong or the DBtreeview plugin does not support sort for multitable tree .would really appreciate your help .Thank you .

---

<div class="post-metadata">

**Author:** ![sanneke](https://avatars.discourse-cdn.com/v4/letter/s/f9ae1b/32.png) [@sanneke](https://forum.servoy.com/u/sanneke)\
**Post date:** [January 26, 2011, 4:32pm UTC](https://forum.servoy.com/t/dbtreeview-multiple-table-tree-not-able-to-sort-child-nodes/13454/2 "2011-01-26T16:32:19Z")

</div>

Hi,

Here a sample that also sort the child nodes, as you can see you can set a calc:

```auto
var _binding = elements.dbtreeview.createBinding(foundset.getServerName(), foundset.getTableName())
		_binding.setImageURLDataprovider('tree_image');
		_binding.setChildSortDataprovider('sort_calc');
		_binding.setNRelationName('nav_menu_items_to_nav_menu_items$parent_id');
		_binding.setTextDataprovider('display_description');
		_binding.setMethodToCallOnClick(globals.svy_nav_tree_node_selected, 'menu_item_id');	
	
		elements.dbtreeview.addRoots(foundset);

```

The calc could be something like this:

```auto
function sort_calc()
{
	return 'sort_order asc';
}

```

---

<div class="post-metadata">

**Author:** ![nestrocuation](https://avatars.discourse-cdn.com/v4/letter/n/e19adc/32.png) [@nestrocuation](https://forum.servoy.com/u/nestrocuation)\
**Post date:** [January 28, 2011, 4:16pm UTC](https://forum.servoy.com/t/dbtreeview-multiple-table-tree-not-able-to-sort-child-nodes/13454/3 "2011-01-28T16:16:36Z")

</div>

Hey i actually did the same way u suggested,

> first\_bind.setChildSortDataprovider(first\_sort\_dp) // first\_sort\_dp-calculation which returns string (string : “second\_bind\_name asc”)
> 
> function first\_sort\_dp  
> {  
> return ‘second\_bind\_name asc’  
> }

---

<div class="post-metadata">

**Author:** ![patrick](https://avatars.discourse-cdn.com/v4/letter/p/b2d939/32.png) [@patrick](https://forum.servoy.com/u/patrick)\
**Post date:** [January 28, 2011, 4:29pm UTC](https://forum.servoy.com/t/dbtreeview-multiple-table-tree-not-able-to-sort-child-nodes/13454/4 "2011-01-28T16:29:17Z")

</div>

You should set the **name** of the dataprovider, not its value. Try

```auto
first_bind.setChildSortDataprovider("first_sort_dp")

```

---

<div class="post-metadata">

**Author:** ![nestrocuation](https://avatars.discourse-cdn.com/v4/letter/n/e19adc/32.png) [@nestrocuation](https://forum.servoy.com/u/nestrocuation)\
**Post date:** [February 11, 2011, 5:48pm UTC](https://forum.servoy.com/t/dbtreeview-multiple-table-tree-not-able-to-sort-child-nodes/13454/5 "2011-02-11T17:48:04Z")

</div>

Thank you it worked .
