-- Hierarchical Tree Example

--

-- The first action will typically be to populate the

-- hierarchical tree (htree) with data.

 

DECLARE

   htree   ITEM;

BEGIN

   -- Find the tree itself.

   htree := Find_Item('tree_block.htree3');

 

   -- Sets the record group and causes the data to display.

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

END;

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

 

-----Another Heirarchical tree Example :

 

create one non database block e.g. tree_block then
add hieraachical control item in that. e.g htree
create record group fron record group node e.g. htree_rg
select 1, level, ename,NULL,TO_CHAR(empno)
from emp
start with mgr IS NULL
connect by prior empno = mgr
//
and apply this record group to htree hierarchiacl tree through property pallet.
//

trigger at tree_block name is WHEN_TREE_NODE_SELECTED
DECLARE
v_htree ITEM;
node_value VARCHAR2(100);
BEGIN
Message('Working... (0%)'|| :SYSTEM.TRIGGER_NODE, NO_ACKNOWLEDGE);

-- Find the tree id.
v_htree := Find_Item('tree_block.htree');

-- Find the value of the node clicked on.
-- The SYSTEM.TRIGGER_NODE environment variable is the node the user
-- clicked on.
node_value := Ftree.Get_Tree_Node_Property(v_htree,
:SYSTEM.TRIGGER_NODE, Ftree.NODE_VALUE);

-- Modify the Where Clause in the EMP Block.
SET_BLOCK_PROPERTY('emp', DEFAULT_WHERE, 'empno = ' || node_value);
GO_BLOCK ('emp');
EXECUTE_QUERY;
END;
/


ADD TRIGGER WHEN-NEW-FORM-INSTANCE AT FORM LEVEL
DECLARE
rg_num NUMBER;
v_htree ITEM;
BEGIN
rg_num := POPULATE_GROUP('htree_rg');
v_htree := FIND_ITEM('tree_block.htree');
FTREE.POPULATE_TREE(v_htree);
END;
//


note :- at every level fire one trigger on-error if you get error coding is
null;

 

 

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

 

 

-- Tree Node Expansion Example

--

-- This code will expand all nodes in a tree.

 

DECLARE

 

   htree   ITEM;

node     ftree.node;

BEGIN

   -- Find the tree itself.

   htree := Find_Item('tree_block.htree3');

 

   -- Find the root node of the tree.

   node  := Ftree.Find_Tree_Node(htree, '');

 

   -- Loop through all nodes and expand each one if it is collapsed.

   WHILE NOT Ftree.ID_NULL(node) LOOP

      state := Ftree.Get_Tree_Node_Property(htree, node, Ftree.NODE_STATE);

      IF state = Ftree.COLLAPSED_NODE THEN

         Ftree.Set_Tree_Node_Property(htree, node, Ftree.NODE_STATE, Ftree.EXPANDED_NODE);

 

      END IF;

      node := Ftree.Find_Tree_Node(htree, '', search_root => node);

   END LOOP;

END;

 

 

-- Delete Tree Node Example

--

-- This code will delete all tree nodes marked as selected.  See the

-- Ftree.Set_Tree_Selection built-in for a definition of "selected".

 

DECLARE

   htree         ITEM;

   num_selected  NUMBER;

BEGIN

   -- Find the tree itself.

   htree := Find_Item('tree_block.htree3');

 

   -- Find the number of nodes marked as selected.

 

   num_selected := Ftree.Get_Tree_Property(htree, Ftree.SELECTION_COUNT);

 

   -- Loop through nodes and delete them. Since nodes are internally

   -- re-numbered when one is deleted, be sure to loop in reverse

   -- order from last to first.

   FOR j IN num_selected..1 LOOP

      Ftree.Delete_Tree_Node(htree, Ftree.Get_Tree_Selection(htree, j));

   END LOOP;

END;

 

 

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

 

 

You can add a node to a hierarchical tree one at a time or by populating a tree with values contained in a record group or query.

 

You can add values to a tree by using these built-in subprograms:

 

n          Add_Tree_Node

 

n          Delete_Tree_Node

 

n          Find_Tree_Node

 

n          Get_Tree_Node_Parent

 

n          Get_Tree_Node_Property

 

n          Get_Tree_Property

 

n          Get_Tree_Selection

 

n          Set_Tree_Node_Property

 

n          Set_Tree _Property

 

n          Set_Tree_Selection

 

n          Add_Tree_Data

 

n          Populate_Group From_Tree

 

n          Populate_Tree

 

 

 

Note: If you need to reference the pseudo root of the tree, use the constant FTREE.ROOT_NODE.  All built-ins are located in the FTREE built-in package.

 

 

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

 

 

You can add data to a tree view by:

 

n          Populating a tree with values contained in a record group or query by using the Populate_Tree built-in.

 

n          Adding data to a tree under a specific node by using the Add_Tree_Data built-in.

 

n          Modifying elements in a tree at runtime by using built-in subprograms.

 

n          Adding or deleting nodes and the data elements under the nodes.

 

Note: All built-ins are located in the FTREE built-in package.

 

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

 

Format of data used to populate a hierarchical tree

 

 

The columns in the record groups or queries used to populate a hierarchical tree are:

 

n          Initial state

 

n          Node tree depth

 

n          Label for the node

 

n          Icon for the node

 

n          Data

 

For example, the data in the table below would produce the following hierarchical tree:

  +  - Car

  |

  -  - Airplane

     | - Boeing

     | - Boeing

 

 

Initial State       Depth               Label                Icon     Data

-1                     1                      'Car'                 ''           'car'

0                      2                      'Honda'            ''           'civic'

1                      1                      'Airplane'          ''           'plane'

0                      2                      'Boeing'            ''           '747'

0                      2                      'Boeing'            ''           '757'

 

 

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

 

Example 2 :

 

Note :

 

You can add a node to a hierarchical tree one at a time or by populating a tree with values contained in a record group or query.

 

A. There are 2 ways to populate a hierarchical tree in Forms as mentioned above:

 

            §         Using a record group / query 

 

                       

The tree is populated with a record group...

 

 HTREE := FIND_ITEM('BL_TREE.MENU');

 

V_IGNORE := POPULATE_GROUP('RG_TREE');

 

FTREE.SET_TREE_PROPERTY(HTREE, FTREE.RECORD_GROUP,'RG_TREE');

 

 

... , which is itself(i.e record group) populated with a CONNECT BY query.

 

 

SELECT STATUS, LEVEL, LABEL, ICON, VALUE

 

FROM MENU

 

CONNECT BY PRIOR ID = MASTER

 

START WITH MASTER IS NULL

 

 

            §         Building the tree with the Add_Tree_Node() built-in

 

 

 

B. The Forms tree needs five column to work correctly:

 

 

 SELECT STATUS, LEVEL, LABEL, ICON, VALUE   FROM MENU

 

 Four of them come from the table:

 

 

 For Example ,The table MENU that contains the menu options :

 

 

CREATE TABLE MENU

 

(

 

  ID      NUMBER(5),                                        -- Unique identifiant  eg (empno)

 

  LABEL   VARCHAR2(128 BYTE),               -- Tree label

 

  ICON    VARCHAR2(40 BYTE),                  -- Icon name

 

  MASTER  NUMBER(5),                                -- Parent ID   eg (mgr)

 

  STATUS  NUMBER(1)      DEFAULT 1,      -- Initial status of the node

 

  VALUE   VARCHAR2(128 BYTE)                 -- Dialog name to call   

 

)

 

 

ICON          contains the icon name (without extension) attached to the node(can be null).

 

STATUS     It is the initial status of the  node and can take one of the three possible values:

 

                        §         0 normal (Not expandable)

 

                        §         1 expanded

 

                        §         -1 collapsed

 

LABEL         that is the visible label of the node.

 

VALUE        that contains the data / value of the node

 

LEVEL         is a “CONNECT BY” specific pseudo-column specifies the depth at which the individual node appears.

 

 

 

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

 

Manipulating a hierarchical tree at runtime

 

 

Form Builder provides triggers that you can use to respond to events that occur when the end user interacts with the hierarchical tree at runtime.

 

n          When-Tree-Node-Activated

 

n          When-Tree-Node-Expanded

 

n          When-Tree-Node-Selected

 

At runtime, you can programmatically add, remove, modify, or evaluate elements in a hierarchical tree by using the following built-in subprograms:

 

n          Add_Tree_Data

 

n          Add_Tree_Node

 

n          Delete_Tree_Node

 

n          Find_Tree_Node

 

n          Get_Tree_Node_Parent

 

n          Get_Tree_Selection

 

n          Populate_Group From_Tree

 

n          Populate_Tree

 

n          Set_Tree_Selection

 

Note: All built-ins are located in the FTREE built-in package.

 

 

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

Populating a hierarchical tree

 

You can populate a hierarchical tree with values contained in a Record Group or Query Text by using the following built-in subprogram:

 

n          Populate_Tree

 

n          Add_Tree_Data

 

Note: All built-ins are located in the FTREE built-in package.

 

 

 

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

Setting hierarchical tree item properties

 

To set a hierarchical tree item property in Form Builder:

 

1          In the Object Navigator, double-click the object icon beside the desired hierarchical tree.

 

2          In the Property Palette, select the property you want to set.

 

3          Set the selected property to the desired setting.

 

You can set properties during runtime by using the following built-ins:

 

n          Get_Tree_Node_Property

 

n          Get_Tree_Property

 

n          Set_Tree_Node_Property

 

n          Set_Tree _Property

 

Note: All built-ins are located in the FTREE built-in package.

 

 

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

 

Specifying an initial value for a hierarchical tree

 

To specify an initial value for a hierarchical tree:

 

1          In the Object Navigator, double-click the object icon beside the desired hierarchical tree object to display the Property Palette.

 

2          Under the Functional node, indicate the Record Group or Query Text that contains the initial values.

 

Note: These are indicators of the initial values, but nothing appears without populating the tree with the Populate_Tree built-in.

 

 

 

 

================================================== 

A.

 

FUNCTION FIND_TREE_NODE

(item_id/item_name ITEM / VARCHAR2,

search_string VARCHAR2, ---‘ROOT’ or can be null ‘ 

search_type NUMBER,       --- Ftree.FIND_NEXT

search_by NUMBER,          ---  Ftree.NODE_VALUE / NODE_LABEL

search_root NODE,              ---  Ftree.ROOT_NODE or can be null ‘ ‘

start_point NODE);              ---  Ftree.ROOT_NODE   

 

 

item_name                  Specifies the name of the object created at design time.  The data type of the name is VARCHAR2 string.

Item_id                       Specifies the unique ID that Form Builder assigns to the item when created.

                                    Use the FIND_ITEM built-in to return the ID to an appropriately typed variable.  The data type of the ID is ITEM.

search_string              Specifies the VARCHAR2 search string.

search_type                Specifies the NUMBER search type.

                                    Possible values are:FIND_NEXT . FIND_NEXT_CHILD  Searches just the children of the search_root node.

search_by                   Specifies the NUMBER to search by. Possible values are:NODE_LABEL . NODE_VALUE

search_root                Specifies the root of the search tree.

start_point                  Specifies the starting point in the NODE search.

 

 

Example :

 

FIND_TREE_NODE examples (Refer to 6i reference with diagrams)

 

/* 

 

** Built-in:  FIND_TREE_NODE

*/

 

-- This code finds a node with a label of "Doran"

-- within the subtree beginning with the a node

-- with a label of "Zetie".

 

DECLARE

   htree         ITEM;

   find_node     Ftree.NODE;

BEGIN

   -- Find the tree itself.

   htree := Find_Item('tree_block.htree3');

 

 

   -- Find the node with a label "Zetie".

   find_node := Ftree.Find_Tree_Node(htree, 'Zetie', Ftree.FIND_NEXT,

                 Ftree.NODE_LABEL, Ftree.ROOT_NODE, Ftree.ROOT_NODE);

 

 

 

   -- Find the node with a label "Doran"

   -- starting at the first occurance of "Zetie".

   find_node := Ftree.Find_Tree_Node(htree, 'Doran', Ftree.FIND_NEXT,

                Ftree.NODE_LABEL, find_node, find_node);

 

   IF NOT Ftree.ID_NULL(find_node) then

      ...

   END IF;

END;

 

 

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

 

B.

 

PROCEDURE DELETE_TREE_NODE

(item_id/item_name  ITEM / VARCHAR2,

node NODE); ------  Ftree.ROOT_NODE

 

 

Built-in Type   unrestricted procedure

Enter Query Mode  no

 

Parameters

 

item_name      Specifies the name of the object created at design time.  The data type of the name is VARCHAR2 string.

Item_id           Specifies the unique ID that Form Builder assigns to the item when created.

                        Use the FIND_ITEM built-in to return the ID to an appropriately typed variable. The data type of the ID is ITEM.

node                Specifies a valid node.

 

 

Usage Notes  -------Removing a branch node also removes all child nodes.

 

 

Example :

 

DELETE_TREE_NODE examples

 

/* 

 

** Built-in:  DELETE_TREE_NODE

*/

 

-- This code finds a node with the label "Zetie"

-- and deletes it and all of its children.

 

DECLARE

   htree         ITEM;

   delete_node   FTREE.NODE;

BEGIN

   -- Find the tree itself.

   htree := Find_Item('tree_block.htree3');

 

   -- Find the node with a label of "Zetie".

   -- Start searching from the root of the tree.

   delete_node := Ftree.Find_Tree_Node(htree,

                                       'Zetie',

 

                                       Ftree.FIND_NEXT,

                                       Ftree.NODE_LABEL,

                                       Ftree.ROOT_NODE,

                                       Ftree.ROOT_NODE);

 

   -- Delete the node and all of its children.

   IF NOT Ftree.ID_NULL(delete_node) then

      Ftree.Delete_Tree_Node(htree, delete_node);

   END IF;

END;

 

 

 

 

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

 

C.

 

FUNCTION ADD_TREE_NODE

(item_id/item_node ITEM / VARCHAR2,

node FTREE.NODE,          ------  Ftree.ROOT_NODE

offset_type NUMBER,      ------   Ftree.PARENT_OFFSET / Ftree.SIBLING_OFFSET

offset NUMBER,                -----   If PARENT_OFFSET then( 1-n or LAST_CHILD) elsif SIBLING_OFFSET then(NEXT_NODE or PREVIOUS_NODE)

state NUMBER,                 -----   COLLAPSED_NODE / EXPANDED_NODE / LEAF_NODE   ( -1,0,1)

label VARCHAR2,             ----     Node label  (eg MOD_DESC)

 icon VARCHAR2,             ----     Filename for node’s icon

value VARCHAR2);           ---      Varchar2 value of the node (eg ‘ROOT’)

 

 

Built-in Type   unrestricted procedure

Returns  NODE

Enter Query Mode  no

 

Parameters

 

item_name      Specifies the name of the object created at design time.  The data type of the name is VARCHAR2 string.

Item_id           Specifies the unique ID that Form Builder assigns to the item when created.

                        Use the FIND_ITEM built-in to return the ID to an appropriately typed variable.The data type of the ID is ITEM.

node                Specifies a valid node.

offset_type     Specifies the type of offset for the node. Possible values are:PARENT_OFFSET / SIBLING_OFFSET

offset               Indicates the position of the new node.If offset_type is PARENT_OFFSET,  then offset can be either 1-n or LAST_CHILD.

                        If offset_type is SIBLING_OFFSET, then offset can be either NEXT_NODE or PREVIOUS_NODE.

state                Specifies the state of the node. Possible vaues are:COLLAPSED_NODE / EXPANDED_NODE / LEAF_NODE

label                The displayed text for the node.

icon                 The filename for the node’s icon.

value               Specifies the VARCHAR2 value of the node.

 

 

Example :

 

ADD_TREE_NODE examples

 

/* 

 

** Built-in:  ADD_TREE_NODE

*/

 

-- This code copies a value from a Form item and

-- adds it to the tree as a top level node.  The

-- value is set to be the same as the label.

 

DECLARE

   htree         ITEM;

   top_node      FTREE.NODE;

   new_node      FTREE.NODE;

   item_value    VARCHAR2(30);

BEGIN

   -- Find the tree itself.

   htree := Find_Item('tree_block.htree3');

 

   -- Copy the item value to a local variable.

   item_value := :wizard_block.new_node_data;

 

 

   -- Add an expanded top level node to the tree

   -- with no icon.

   new_node := Ftree.Add_Tree_Node(htree,

                                   Ftree.ROOT_NODE,

                                   Ftree.PARENT_OFFSET,

                                   Ftree.LAST_CHILD,

                                   Ftree.EXPANDED_NODE,

                                   item_value,

                                   NULL,

                                   item_value);

END;

 

 

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

 

D.

Specifies the selection of a single node.Returns the data node indicated by selection. Selection is an index into the list of selected nodes.

 

FUNCTION GET_TREE_SELECTION

(item_id/item_name  ITEM,

selection NUMBER);  ------Specifies the selection of a single node.

 

Returns  FTREE.NODE

Built-in Type   unrestricted function

Enter Query Mode  no

 

Parameters

 

item_name      Specifies the name of the object created at design time.  The data type of the name is VARCHAR2 string.

Item_id           Specifies the unique ID that Form Builder assigns to the item when created.

                        Use the FIND_ITEM built-in to return the ID to an appropriately typed variable. The data type of the ID is ITEM.

selection         Specifies the selection of a single node.

 

Example :

 

GET_TREE_SELECTION examples

 

/* 

 

** Built-in:  GET_TREE_SELECTION

*/

 

-- This code will process all tree nodes marked as selected.  See the

-- Ftree.Set_Tree_Selection built-in for a definition of "selected".

 

DECLARE

   htree         ITEM;

   num_selected  NUMBER;

   current_node  FTREE.NODE;

BEGIN

   -- Find the tree itself.

   htree := Find_Item('tree_block.htree3');

 

   -- Find the number of nodes marked as selected.

   num_selected := Ftree.Get_Tree_Property(htree, Ftree.SELECTION_COUNT);

 

 

   -- Loop through selected nodes and process them. If you are deleting

   -- nodes, be sure to loop in reverse!

   FOR j IN 1..num_selected LOOP

      current_node := Ftree.Get_Tree_Selection(htree, j);

      ...

   END LOOP;

END;

 

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

 

E.

 

Specifies the selection of a single node

 

PROCEDURE SET_TREE_SELECTION

(item_id / item_name ITEM / VARCHAR2, 

node NODE,                                             ----- any valid node (eg new_node1)

selection_type NUMBER);                     -----  SELECT_ON / SELECT_OFF / SELECT_TOGGLE  

 

 

Built-in Type   unrestricted procedure

Enter Query Mode  no

 

Parameters

 

item_name                  Specifies the name of the object created at design time.  The data type of the name is VARCHAR2 string.

Item_id                       Specifies the unique ID that Form Builder assigns to the item when created.

                                    Use the FIND_ITEM built-in to return the ID to an appropriately typed variable.The data type of the ID is ITEM.

node                            Specifies a valid node.

selection_type            Specifies the type of selection.SELECT_ON   Selects the node.SELECT_OFF   Deselects the node.

                                    SELECT_TOGGLE   Toggles the selection state of the node.

 

 

Example :

 

SET_TREE_SELECTION examples

 

/* 

 

** Built-in:  SET_TREE_SELECTION

*/

 

-- This code could be used in a WHEN-TREE-NODE-EXPANDED

-- trigger and will mark the clicked node as selected.

 

DECLARE

   htree         ITEM;

BEGIN

   -- Find the tree itself.

   htree := Find_Item('tree_block.htree3');

 

   -- Mark the clicked node as selected.

   Ftree.Set_Tree_Selection(htree, :SYSTEM.TRIGGER_NODE, Ftree.SELECT_ON);

END;

 

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

 

F.

 

Returns property values of the specified hierarchical tree.

 

FUNCTION GET_TREE_PROPERTY

(item_id/item_name ITEM/VARCHAR2,

property NUMBER);  ---- DATASOURCE / RECORD_GROUP / QUERY_TEXT / NODE_COUNT / SELECTION_COUNT /

                                     ----- ALLOW_EMPTY_BRANCHES / ALLOW_MULTI_SELECT

 

 

item_name      Specifies the name you gave the object when you created it.  The data type of the name is VARCHAR2 string.

Item_id           Specifies the unique ID that Form Builder assigns to the item when created. Use the FIND_ITEM built-in to return the ID to an appropriately typed variable.

                        The data type of the ID is ITEM.

property          Specify one of the following properties:

                        DATASOURCE   Returns the source used to initially populate the hierarchical tree,

                        either in Form Builder or by using the SET_TREE_PROPERTY built-in.

                        Returns EXTERNAL if neither property was set in Form Builder.

                        RECORD_GROUP   Returns the RecordGroup used to initially populate the hierarchical tree,

                        either in Form Builder or by using the SET_TREE_PROPERTY built-in. This may be a null string.

                        QUERY_TEXT   Returns the text of the query used to initially populate the hierarchical tree,

                        either in Form Builder or by using the SET_TREE_PROPERTY built-in.. This may be a null string.

                        NODE_COUNT   Returns the number of rows in the hierarchical tree data set.

                        SELECTION_COUNT   Returns the number of selected rows in the hierarchical tree.

                        ALLOW_EMPTY_BRANCHES   Returns the character string TRUE or FALSE.

                        ALLOW_MULTI-SELECT   Returns the character string TRUE or FALSE.

 

 

 

Usage Notes     ----The values returned by datasource RECORD_GROUP and QUERY_TEXT do not necessarily reflect the current data or state of the tree(during runtime).

                        The values returned are those that were set in Form Builder(during design time) and not those set using the SET_TREE_PROPERTY built-in.

 

Example :

 

GET_TREE_PROPERTY examples

 

/* 

 

** Built-in:  GET_TREE_PROPERTY

*/

 

-- This code could be used to find out how many nodes are

-- in a given tree.

 

DECLARE

   htree         ITEM;

   node_count    NUMBER;

BEGIN

   -- Find the tree itself.

   htree := Find_Item('tree_block.htree3');

 

   -- Get the node count of the tree.

   node_count := Ftree.Get_Tree_Property(htree, Ftree.NODE_COUNT);

 

   ...

END;

 

 

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

 

PROCEDURE SET_TREE_PROPERTY

  (item_name/item_id VARCHAR2,

   property NUMBER,

   value NUMBER / VARCHAR2 / RECORDGROUP );

 

 

Built-in Type   unrestricted procedure

Enter Query Mode  no

 

Parameters

 

item_name      Specifies the name of the object created at design time.  The data type of the name is VARCHAR2 string.

Item_id           Specifies the unique ID that Form Builder assigns to the item when created.

                        Use the FIND_ITEM built-in to return the ID to an appropriately typed variable.

                        The data type of the ID is ITEM.

property          Specify one of the following properties:

                        RECORD_GROUP   Replaces the data set of the hierarchical tree with a record group and causes it to display.

                        QUERY_TEXT   Replaces the data set of the hierarchical tree with an SQL query and causes it to display.

                        ALLOW_EMPTY_BRANCHES   Possible values are PROPERTY_TRUE and PROPERTY_FALSE.

value               Specify the value appropriate to the property you are setting:

                        PROPERTY_TRUE  The property is to be set to the TRUE state.

                        PROPERTY_FALSE  The property is to be set to the FALSE state.

 

Example :

 

SET_TREE_PROPERTY examples

 

/* 

 

** Built-in:  SET_TREE_PROPERTY

*/

 

-- This code could be used in a WHEN-NEW-FORM-INSTANCE

-- trigger to initially populate the hierarchical tree

-- with data.

 

DECLARE

   htree         ITEM;

   v_ignore      NUMBER;

   rg_emps       RECORDGROUP;

BEGIN

   -- Find the tree itself.

   htree := Find_Item('tree_block.htree3');

 

   -- Check for the existence of the record group.

   rg_emps := Find_Group('emps');

   IF NOT Id_Null(rg_emps) THEN

      DELETE_GROUP(rg_emps);

 

   END IF;

 

   -- Create the record group.

   rg_emps := Create_Group_From_Query('rg_emps',

             'select 1, level, ename, NULL, to_char(empno) ' ||

             'from emp '                                     ||

             'connect by prior empno = mgr '                 ||

             'start with job = ''PRESIDENT''');

 

   -- Populate the record group with data.

   v_ignore := Populate_Group(rg_emps);

 

   -- Transfer the data from the record group to the hierarchical

 

   -- tree and cause it to display.(Populating the tree with record group at runtime)

   Ftree.Set_Tree_Property(htree, Ftree.RECORD_GROUP, rg_emps);

END;

 

 

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

 

G.

 

Returns the value of the specified property of the hierarchical tree node

 

FUNCTION GET_TREE_NODE_PROPERTY

(item_id/item_name ITEM/VARCHAR2,

node NODE,    -------- name_in('system.trigger_node') or :system.trigger_node

property NUMBER);---- NODE_STATE / NODE_DEPTH / NODE_LABEL / NODE_ICON / NODE_VALUE 

 

Note : SYSTEM.TRIGGER_NODE represents the node the user selected and it returns a value of type NODE

 

Returns  VARCHAR2

Built-in Type   unrestricted function

Enter Query Mode  no

 

Parameters

 

item_name      Specifies the name of the object created at design time.  The data type of the name is VARCHAR2 string.

Item_id           Specifies the unique ID that Form Builder assigns to the item when created.

                        Use the FIND_ITEM built-in to return the ID to an appropriately typed variable.  The data type of the ID is ITEM.

node                Specifies a valid node.

property          Specify one of the following properties:

                        NODE_STATE   Returns the state of the hierarchical tree node.

                        This is either EXPANDED_NODE(i.e 1), COLLAPSED_NODE(i.e -1), or LEAF_NODE(i.e 0 ,non expandable).

                        NODE_DEPTH   Returns the nesting level of the hierarchical tree node.

                        NODE_LABEL   Returns the label

                        NODE_ICON   Returns the icon name

                        NODE_VALUE   Returns the value of the hierarchical tree node.

 

Example :

 

GET_TREE_NODE_PROPERTY examples

 

/* 

 

** Built-in:  GET_TREE_NODE_PROPERTY

*/

 

-- This code could be used in a WHEN-TREE-NODE-SELECTED

-- trigger to return the value of the node that was

-- clicked on.

 

DECLARE

   htree         ITEM;

   node_value    VARCHAR2(100);

BEGIN

   -- Find the tree itself.

   htree := Find_Item('tree_block.htree3');

 

   -- Find the value of the node clicked on.

   node_value := Ftree.Get_Tree_Node_Property(htree, :SYSTEM.TRIGGER_NODE, Ftree.NODE_VALUE);

 

   ...

 

END;

 

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

 

Description

 

Sets the state of a branch node.

 

Syntax

 

PROCEDURE SET_TREE_NODE_PROPERTY

  (item_name/item_id VARCHAR2,

   node FTREE.NODE,

   property NUMBER,

   value NUMBER/VARCHAR2);

 

 

Built-in Type   unrestricted procedure

Enter Query Mode  no

 

Parameters

 

item_name      Specifies the name of the object created at design time.  The data type of the name is VARCHAR2 string.

Item_id           Specifies the unique ID that Form Builder assigns to the item when created.

                        Use the FIND_ITEM built-in to return the ID to an appropriately typed variable.  The data type of the ID is ITEM.

node                Specifies a valid node.

property          Specify one of the following properties:

                        NODE_STATE   Possible values are EXPANDED_NODE, COLLAPSED_NODE, and LEAF_NODE.

                        NODE_LABEL   Sets the label of the node.

                        NODE_ICON   Sets the icon of the node.

                        NODE_VALUE   Sets the value of the node.

value               The actual value you intend to pass.

 

 

Example :

 

SET_TREE_NODE_PROPERTY examples

 

/* 

 

** Built-in:  SET_TREE_NODE_PROPERTY

*/

 

-- This code could be used in a WHEN-TREE-NODE-SELECTED

-- trigger to change the icon of the node clicked on.

 

DECLARE

   htree         ITEM;

   current_node  FTREE.NODE;

   find_node     FTREE.NODE;

BEGIN

   -- Find the tree itself.

   htree := Find_Item('tree_block.htree3');

 

   -- Change it icon of the clicked node.

   -- The icon file will be located using the

   -- UI60_ICON environment variable in client/server

 

   -- or in the virtual directory for web deployment.

   Ftree.Set_Tree_Node_Property(htree, :SYSTEM.TRIGGER_NODE, Ftree.NODE_ICON, 'Open');

END;

 

 

 

 

======================================================================================

 

EXAMPLES  from HmsLive Project :

 

 

Declare

 

new_node ftree.node;

 

begin

 

DEL_NODE := FTREE.FIND_TREE_NODE('left_menu_TREE.tree','ROOT',Ftree.FIND_NEXT,

                 Ftree.NODE_VALUE, Ftree.ROOT_NODE, Ftree.ROOT_NODE);

 

 

FTREE.SET_TREE_SELECTION('left_menu_TREE.tree',NEW_NODE2,FTREE.SELECT_ON);

 

 

            current_node := ftree.get_tree_selection('LEFT_MENU_TREE.TREE',1);

 

svFormName := Ftree.Get_Tree_Node_Property('LEFT_MENU_TREE.TREE',name_in('system.trigger_node'), Ftree.NODE_VALUE);

 

 

 

            new_node2 := Ftree.Add_Tree_Node('left_menu_TREE.tree',

                                   new_node1,

                                   Ftree.PARENT_OFFSET,

                                   Ftree.LAST_CHILD,

                                   Ftree.expanded_NODE,

                                   RECS1.gfd_desc,

                                   NULL,

                                   RECS1.gfd_name);

 

            new_node :=  Ftree.Add_Tree_Node('left_menu_TREE.tree',

                                   Ftree.root_node,

                                   Ftree.PARENT_OFFSET,

                                   Ftree.LAST_CHILD,

                                   Ftree.expanded_NODE,

                                   MODULE_DESC,

                                   NULL,

                                   'ROOT');

           

 

            FTREE.DELETE_TREE_NODE('left_menu_TREE.tree',DEL_NODE);

 

 

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

 

Associated System Variables with tree nodes :

 

  1. :SYSTEM.TRIGGER_NODE_SELECTED

                  SYSTEM.TRIGGER_NODE_SELECTED contains a valid value only during the WHEN-TREE-NODE-SELECTED trigger,

                 indicating whether the trigger is firing for a selection or a deselection. The values are either TRUE or FALSE.

  1. :system.trigger_node

                  SYSTEM.TRIGGER_NODE represents the node the user selected and it returns a value of type NODE