Trees
Trees can be used to display hierarchal
data. Trees are based on a base table. The table must have an
ID column, a Parent ID column, and a display text item. The
following example uses the information in the following
CAR_PARTS table. A car is made up of parts and each part can
have sub-parts. The records that make up the CAR_PARTS table
are shown in Table 11.2 and Figure 11.18.
|
Column Name |
Data Type |
Nullable |
Default |
Primary Key |
|
ID |
NUMBER |
Yes |
- |
- |
|
PARENT_ID |
NUMBER |
Yes |
- |
- |
|
ITEM |
varchar2(20) |
Yes |
- |
- |
When a tree is created, a new page is
created with all the information required to display the tree.
A tree can be complicated to build. It is recommended that the
tree be created first in order to create the page. Then, modify
the page afterwards.
Creating a Tree
The first
step to creating a tree is to navigate to the Shared Component
area of the application. Choose the Trees link in the second
column. This will start the Tree wizard.
1. On the first page
of the wizard, as shown in Figure 11.19, the following
information is required. All of these entries can be left at
their default values.
-
: This is the number of that page which will be
created
-
: Name of the page created.
-
: Template of the region which will
display the tree.
-
: The name of the region. Click Next.
2. The next page,
shown in Figure 11.20, will require:
-
: The name of the tree. Enter in Car Parts.
-
: This is how many levels the
tree will show when first displayed.
-
: The method to provide the starting point.
A Static Value will be used for the example. Normally, this
might be based on a LOV or other page item. Click Next.
3.
On the next page, as shown in Figure 11.21, the Tree
template will be chosen. Each tree still performs in the same
manner; they just vary in the graphics which are shown in the
tree. The Standard Tree will be chosen for this example. Click
Next.
4.
On this page, shown in Figure 11.22, the starting point
for the Tree, the root, will be specified. This will be a
static value, a query, or a popup value depending on what was
selected on page two of the wizard, as was shown in Figure
11.20. Enter the number zero (0). Click Next.
5.
The next page of the wizard, shown in Figure 11.23, is to
select which buttons to include with the Tree. There are three
buttons from which to choose: one to Collapse All nodes of the
tree; one to Expand All nodes of the tree; and, one to Reset the
tree to when it was first rendered. Click Next.
6.
Using the next two pages, shown in Figure 11.24, of the
wizard, the base table for the Tree will be chosen. In this
case, this will be the CAR_PARTS table. The first page is where
the Table Owner will be selected and the table itself will be
selected on the second page. Click Next.
7.
The next page, shown in Figure 11.25, is very important.
This is where the three columns which are required for a Tree
will be specified: the ID; the PARENT ID; and, the LEAF NODE.
The link can be additional information on the part such as a
picture and details. In this example, a link will not be
created. Click Next.
8.
The next page is where optional WHERE and ORDER BY
clauses can be specified for the Query. Click Next.
9.
The summary page is last. It will show all the options
that were included in the wizard. If all looks good, click
Finish.
Creating Trees on
Application Pages
A page will now be created. When running
the page, there will be a region with the tree. If links were
specified for the leaf nodes, each link could navigate to a new
page. The nodes can be collapsed or expanded by the user. To
learn more about the trees, look over the page that was created,
as shown in Figure 11.26.