Re: Hierarchical trees (Calling all examples)

From: <james_rowland_at_my-deja.com>
Date: Thu, 06 Jan 2000 17:38:14 GMT
Message-ID: <852ju3$4ks$1_at_nnrp1.deja.com>


Here is what I did.

I needed to present the user with a list of reports by category in a treeview.

James Rowland (jrowland_at_chis.com)



Step 1 - Create and populate the table

CREATE TABLE REPORTS

(	ID      	NUMBER(3),
	RPTNUM	NUMBER(3),
	NAME    	varCHAR(40),
	PARENT	NUMBER(3),
	DES		varCHAR(255)

);

INSERT INTO REPORTS VALUES
(1, NULL, 'Finance', NULL, NULL);

INSERT INTO REPORTS VALUES
(2, NULL, 'Membership', NULL, NULL);

INSERT INTO REPORTS VALUES
(3, NULL, 'Referrals', NULL, NULL);

INSERT INTO REPORTS VALUES
(4, NULL, 'Weekly Remittance', 1, 'Prints a listing of weekly activity');

INSERT INTO REPORTS VALUES
(5, NULL, 'Member List', 2, 'Prints a list of current members');

INSERT INTO REPORTS VALUES
(6, NULL, 'Superceded Referrals', 3, 'Prints a list of superceded referrals');



Step 2 - Create a record group.

Create a record group named RG1.

Set the record group query property to:

	SELECT -1, level, name, null, name
		FROM reports
		CONNECT BY PRIOR ID = parent
		START WITH parent IS NULL


-------------------------------

Step 3 - Add the Hierarchial Tree control and set properties.

Name the tree HTREE3.

  • The tree control must be the only item in the block. **

Name the data block TREE_BLOCK.

Set the following data BLOCK (TREE_BLOCK) properties:

	Database data block		NO
	Query data source 		None
	Number of record displayed	1

Set the TREE control (HTREE3) properties:

        Record group RG1



Step 4 - Add a trigger

Add the following code to the either the PRE-FORM, WHEN-NEW-FORM- INSTANCE, or WHEN-NEW-BLOCK-INSTANCE trigger.

        DECLARE

	   htree         ITEM;
	   v_ignore      NUMBER;

	BEGIN

	   -- Find the tree itself.

	   htree := Find_Item('TREE_BLOCK.HTREE3');

	   -- Populate the record group.

	   v_ignore := Populate_Group('RG1');

	   -- Assign the record group to the tree

	   Ftree.Set_Tree_Property(htree, Ftree.RECORD_GROUP, 'RG1');

	END;



-------------------------------

Step 5 - Run the form

Sent via Deja.com http://www.deja.com/
Before you buy. Received on Thu Jan 06 2000 - 18:38:14 CET

Original text of this message