Home » Developer & Programmer » Forms » How to make this Hierarchical Tree? (Forms 10.1.2 Win2003)
How to make this Hierarchical Tree? [message #360085] Wed, 19 November 2008 09:14 Go to next message
since
Messages: 18
Registered: May 2008
Junior Member
Hi everybody,
This is the table:
create table TREETEST
(
  CLASS1 VARCHAR2(40) not null,
  CLASS2 VARCHAR2(40),
  CLASS3 VARCHAR2(40),
  NAME   VARCHAR2(40)
);

insert into treetest (CLASS1, CLASS2, CLASS3, NAME)
values ('A1', '', '', 'D1');

insert into treetest (CLASS1, CLASS2, CLASS3, NAME)
values ('A2', '', '', 'D2');

insert into treetest (CLASS1, CLASS2, CLASS3, NAME)
values ('A1', '', '', 'D3');

insert into treetest (CLASS1, CLASS2, CLASS3, NAME)
values ('A1', 'B1', '', 'D4');

insert into treetest (CLASS1, CLASS2, CLASS3, NAME)
values ('A2', 'B2', '', 'D5');

insert into treetest (CLASS1, CLASS2, CLASS3, NAME)
values ('A1', 'B1', 'C1', 'D6');

insert into treetest (CLASS1, CLASS2, CLASS3, NAME)
values ('A2', 'B2', 'C2', 'D7');

insert into treetest (CLASS1, CLASS2, CLASS3, NAME)
values ('A1', 'B2', 'C3', 'D8');


So the table likes following:


CLASS1   CLASS2   CLASS3   NAME
A1                         D1
A2                         D2
A1                         D3
A1       B1                D4
A2       B2                D5
A1       B1       C1       D6
A2       B2       C2       D7
A1       B2       C3       D8



I drag a Hierarchical Tree to the form. When I run this form, I want the Hierarchical Tree seems like following:

|-----A1
|     |-----D1
|     |-----D3
|     |-----B1
|     |     |-----D4
|     |     |-----C1
|     |           |-----D6
|     |-----B2
|           |-----C3
|                 |-----D8
|
|-----A2
|     |-----D2
|     |-----B2
|           |-----D5
|           |-----C2
|                 |-----D7



How can I do that? How to build the record group?

Thanks a lot!
Re: How to make this Hierarchical Tree? [message #360186 is a reply to message #360085] Thu, 20 November 2008 00:27 Go to previous messageGo to next message
djmartin
Messages: 10180
Registered: March 2005
Location: Canberra ACT Australia
Senior Member
Account Moderator
Look at:
Hierarchy Tree
A form with table definition.
http://www.orafaq.com/forum/t/77009/0/unread/67467/#msg_229389
Another form.
http://www.orafaq.com/forum/m/215628/67467/?srch=tree#msg_215628
And another
http://www.orafaq.com/forum/t/83541/67467/
And
http://www.orafaq.com/forum/t/83923/67467/
and from 2005
http://www.orafaq.com/forum/t/32866/67467/
Populate Nth level of Hierarchical tree
http://www.orafaq.com/forum/t/87093/67467/
Icons
http://www.orafaq.com/forum/m/215770/67467/?srch=TRIGGER_NODE#msg_215770
Change the icon on a node.
http://www.orafaq.com/forum/t/90909/67467/
Show Image In Tree
http://www.orafaq.com/forum/t/95682/67467/
FTREE Documentation - Metalink Note:210663.1

David
Re: How to make this Hierarchical Tree? [message #361381 is a reply to message #360085] Wed, 26 November 2008 03:00 Go to previous message
mikeverkimpe
Messages: 30
Registered: April 2007
Location: Belgium
Member

Your table structure is a bit silly, but I gave it a go and came up with this query for your record group.

select 1 status,level,substr(name,1,2) label, null icon, substr(name,1,2) value from
(
select name,class3 master from (select class1 class1, class2||class1 class2, class3||class2||class1 class3, name from treetest) where class3 is not null and name <> class3
union
select name,class2 master from (select class1 class1, class2||class1 class2, class3||class2||class1 class3, name from treetest) where class3 is null and class2 is not null and name <> class2
union
select class3, class2 master from (select class1 class1, class2||class1 class2, class3||class2||class1 class3, name from treetest) where class3 is not null and class2 is not null and class3 <> class2
union
select class2, class1 master from (select class1 class1, class2||class1 class2, class3||class2||class1 class3, name from treetest) where class2 is not null and class1 is not null and class2 <> class1
union
select name,class1 master from (select class1 class1, class2||class1 class2, class3||class2||class1 class3, name from treetest) where class3 is null and class2 is null and class1 is not null and name <> class1
union
select distinct(class1), null master from (select class1 class1, class2||class1 class2, class3||class2||class1 class3, name from treetest) where class1 is not null
)
connect by prior name = master
start with master is null

In your form you can populate the tree item in the when-new-form-instance.

declare

HTREE ITEM;
V_IGNORE NUMBER;


begin


HTREE := FIND_ITEM('BLOCK3.ITEM4');
V_IGNORE := POPULATE_GROUP('RG_TREE');
FTREE.SET_TREE_PROPERTY(HTREE, FTREE.RECORD_GROUP,'RG_TREE');

end;


Previous Topic: Global Variable
Next Topic: How to populate listbox with data from database table?
Goto Forum:
  


Current Time: Sun Dec 04 16:33:22 CST 2016

Total time taken to generate the page: 0.15544 seconds