View source | Discuss this page | Page history | Printable version   

How to Define a Table as a Tree

Bulbgraph.png   This feature, sponsored through Agility ERP, is available from Openbravo PR14Q2



If a table contains data that is bound to be represented hierarchically using a tree, the developer can define tree categories for it.

Defining tree categories for a table has two advantages:

Table Tree Category subtab

The Table Tree Category tab allows to define tree categories for tables. It is possible to define several tree categories for a table, if it can be expresses in different ways hierarchically.

Enabling the Table Tree Category subtab

The Table Tree Category is a subtab of the header tab of the Tables and Columns windows. It is hidden by default, in order to enable it the user has to check the table Is Tree flag.


Tree Structures

There are three tree structures available:

AD Tree Structure

If this structure is used, the information needed to handle the hierarchy of the tree data will be stored internally by Openbravo in the AD_Tree and AD_TreeNode tables.

Link to Parent Tree Structure

This structure should be used if the table contains a column that represents the parent node of the record. For instance, consider a table called Employee, that has a column called reportsTo. This column points to the employee who the current employee must report to.

Custom Tree Structure

There may be other cases where the information needed to handle the hierarchy is stored within the table but by means other than a column pointing directly to the parent node. For instance, this is the case of the AD_Tab table, where the hierarchy of the tabs is defined using the seqNo and tabLevel columns. In this case, the user has to provide a manual datasource to handle the tree hierarchy.

Common Fields for all Tree Structures

The following fields apply to all trees, regardless of its tree structure:

ADTree Structure Fields


LinkToParent Structure Fields


Custom Tree Structure Fields

Enabling the Tree Grid View in a Tab


In order to enable the Tree Grid View in a Tab, the system admin has to pick a tree category in the Table Tree Category field.

By default, the root nodes will be those whose parent is null or '0'. The user can overwrite this by defining a HQL Where Clause for Root Nodes that will be used to pick the root nodes for this tab.


Defining a Tree Selector

Tables that have trees defined are bound to be used in Tree Selectors. Tree Selector are a variant of the Openbravo selectors, that take advantage of the hierarchical data of the tables, allowing to use trees for filtering and picking records.

The documentation on how to define a tree selector can be found here.

Retrieved from ""

This page has been accessed 30,632 times. This page was last modified on 25 May 2014, at 20:01. Content is available under Creative Commons Attribution-ShareAlike 2.5 Spain License.