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 Go to next message](/forum/theme/orafaq/images/down.png) |
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 #361381 is a reply to message #360085] |
Wed, 26 November 2008 03:00 ![Go to previous message Go to previous message](/forum/theme/orafaq/images/up.png) |
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;
|
|
|
Goto Forum:
Current Time: Sun Feb 09 08:56:17 CST 2025
|