How the Persons Tree View Was Defined

Previous Next

The second tab page of the Travel Agency Catalog illustrates these features:

· Single Tree View Node with several Child Nodes.

 

· Use of hard-coded names such as Persons, Customers and Staff in a tree view.

 

· An indication of the number of Scheduled Tours a customer participated in.

To define the Persons tree view:

1. On the tab control of the Travel Agency Project Catalog, insert a new tab page and change the Page Title to Persons.
2. On the Persons tab page, insert a Tree View with eight Tree View Nodes.

For the Tree View object, set Root Nodes to Tree View Node 1.

For Tree View Node 1, set Child Nodes to:

Tree View Node 2

Tree View Node 3

Tree View Node 4

For Tree View Node 2, set Child Nodes to Tree View Node 5.

For Tree View Node 3, set Child Nodes to Tree View Node 7.

For Tree View Node 4, set Child Nodes to Tree View Node 8.

For Tree View Node 5, set Child Nodes to Tree View Node 6.

3. For Tree View Node 1, set SQL Query to:

SELECT  DISTINCT 'Person'

FROM    person

4. For Tree View Node 2, set SQL Query to:

SELECT  DISTINCT 'Customer'

FROM    person

5. For Tree View Node 3, set SQL Query to:

SELECT  DISTINCT 'Guide'

FROM    guide

6. For Tree View Node 4, set SQL Query to:

SELECT  DISTINCT 'Staff'

FROM    staff

7. For Tree View Node 5, set SQL Query to:

SELECT  DISTINCT SUBSTR(family_name,1,1) first_char

FROM    person

WHERE   guide = 'N'

AND     staff = 'N'

8. For Tree View Node 6, set SQL Query to:

SELECT  p.family_name||',  '||

       p.first_name||

       '  ('||COUNT(pt.person_id)||')'

FROM    person p

       ,participant pt

WHERE   SUBSTR(p.family_name,1,1)=:FIRST_CHAR

AND    p.person_id    = pt.person_id(+)

AND    p.guide        = 'N'

AND    p.staff        = 'N'

GROUP BY p.family_name,p.first_name

NOTE:

In this SQL statement, note the following:

· You can concatenate columns in a SELECT statement to display more than one column in a tree view.
·
· You can refer to an alias name (:first_char) used in the SQL Query of the parent tree view node.
·
· You can use outer joins for showing the customers that did not participate in any scheduled tour.
9. For Tree View Node 7, set property SQL Query to:

SELECT  family_name||', '||first_name

FROM    guide

10. For Tree View Node 8, set property SQL Query to:

SELECT  family_name||', '||first_name

FROM    staff

11. Choose appropriate icons and change the layout of the Persons tree view.

To let the tree view on the second tab page resize automatically within the catalog, add the following line to the Startup Actions property of the Catalog:

ac-rel(*Page 2, set-workarea, Tree View 1)