Creating a Tree Item

We will use the following design to create a tree item based on a query and show how to get the EMP details by EMPNO for each tree node selection:

A block named TREE_BLOCK with an item of type Tree named HTREE can be used. This item can belong to the primary canvas of the console window. Drag the tree item to cover a vertical rectangle visible enough to picture a hierarchical structure.

The operations of expand and collapse are simulated as a toggle when a particular node is expanded or collapsed by clicking on it.

The operations of Expand All and Collapse All are simulated as a toggle when a particular node is expanded or collapsed. These are relative to the depth of this starting node.

A control block named CTRL_BLK with four iconic push buttons PB_EXPAND, PB_EXPAND_ALL, PB_COLLAPSE, and PB_COLLAPSE_ALL for the expand, expand all, collapse and collapse all operations on selected Tree nodes can be used. Expand and collapse are explained in the second point; Expand all and Collapse all are provided by clicking each node. These functions are also provided by means of buttons to give greater flexibility to the user .

A data block EMP gets the details for the node selected EMPNO.

Begin by initializing the tree item with a data query based on a SELECT with CONNECT BY and START WITH clauses. This has to be specified in the Data Query property of the tree item: