# DBTreeview

{% hint style="info" %}
*<mark style="color:blue;">**Content under construction**</mark>*
{% endhint %}

Servoy extra components contains two tree components. The difference between the two is the model, the dbtreeview is based on foundset(s) while treeview is based on dataset.

DbTreeview shows multiple tree levels based on relation. From top foundset (datasource), one can show related nodes specified by a relation. Note that each relation is a database query , so for performance should not abuse the tree expand (from javascript). The tree works lazy and initializes data as requested.

Usual tree features are included, show a node checkbox, node image, tooltip, click callback, expand node... More information about model/api can be seen in Servoy Developer.

This component is a porting to NG of Servoy's DBTreeView bean, you can find more details about the migration here: <https://wiki.servoy.com/display/DOCS/Upgrading+to+Servoy+8.x.x#UpgradingtoServoy8.x.x-DBTreeView>

Here is a sample code of the tree initialization:

```javascript
//set the relation to discover other nodes (when clicked open)
elements.dbtreeview.setNRelationName(controller.getDataSource(), 'book_nodes_to_book_nodes_parent_childs');
		
//set the name of dataprovider to use for text display on a node
elements.dbtreeview.setTextDataprovider(controller.getDataSource(), 'label_text');

//set the method to call and dataprovider value to pass when node clicked
elements.dbtreeview.setCallBackInfo(controller.getDataSource(), globals.node_selected,'node_id');

//search the root node(s)
controller.find();
parent_id = 0;
controller.search();

//set the root node(s) and set the name of dataprovider to use for text display on a node
elements.dbtreeview.addRoots(foundset);

var pathAr = new Array(1,2,3);
elements.dbtreeview.setSelectionPath(pathAr);
```

## Table of contents

* [DBTreeView properties](#dbtreeview-properties)
* [DBTreeView events](#dbtreeview-events)
* [DBTreeView API](#dbtreeview-api)
* [DBTreeView Types](#dbtreeview-types)

## DBTreeView properties

DBTreeView properties can be found [here](/reference/servoyextensions/ui-components/visualization/dbtreeview.md#properties)

The component has only one public property, component should be handled via API.

## DBTreeView Events

DBTreeView events can be found [here](/reference/servoyextensions/ui-components/visualization/dbtreeview.md#events)

## DBTreeView API

DBTreeView API methods can be found [here](/reference/servoyextensions/ui-components/visualization/dbtreeview.md#api)

## DBTreeView Types

DBTreeView types can be found [here](/reference/servoyextensions/ui-components/visualization/dbtreeview.md#types)


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.servoy.com/guides/develop/application-design/ui-components/visualization/dbtreeview.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
