Solved

How can i Use a Heirarcical Tree in Forms 6i

Posted on 2002-06-16
3
3,252 Views
Last Modified: 2008-02-26
Hello every 1 My name is zeeshan i m Getting Problem with heirarcial Tree in forms 6i it gives an excpetion of invalid tree data ...

Please tell me how can i use htree in forms
with proper record group query thanks
0
Comment
Question by:zeeshan21m
3 Comments
 
LVL 6

Accepted Solution

by:
M-Ali earned 200 total points
ID: 7081302
The record group for hierarchical tree should have 5 columns:
1) Initial State - specifies which nodes are expanded/collapsed. Values are 0, 1, -1.
2) Level of node tree depth
3) Displayed value on node
4) Icon name
5) Data -- value associated with the node.


Here are the steps you need to follow using emp table in Scott schema:

1) Create a block B1. Create a hierarchical tree item TREE1.

2) Create another block B2. Create a push-button PB1.

3) Create Record Group RG1 with the following query:
SELECT 1, LEVEL, ename, '', TO_CHAR(empno)
FROM emp
CONNECT BY PRIOR empno = mgr
START WITH job = 'PRESIDENT'

4) Create WHEN-BUTTON-PRESSED trigger on PB1:
DECLARE
  my_tree ITEM;
  my_num  NUMBER;

BEGIN
  my_tree := Find_Item('B1.TREE1');
  my_num  := POPULATE_GROUP('RG1');
  FTREE.SET_TREE_PROPERTY(my_tree, FTREE.RECORD_GROUP, 'RG1');
END;

5) Create layout and run the program. Click PB1 to populate the tree.


HTH
Ali
0
 
LVL 47

Expert Comment

by:schwertner
ID: 7083093
I use hierarchical trees in my Human Resources Info System. Before using them you have to know some "underground" facts. First at all the tree item ha to be the only item in the block. The second fact is very important - due a bug in Forms a tree CANNOT have more then 1800 elements (leaves, subtrees, etc.) So if you try to use huge trees (what is not a good solution) you will run into this bug.

I provide you with the body of the package I use to deal with the hierarchical tree. My hope is that you will fid it useful.

Good luck!

PROCEDURE POPULATE_TREE (p_tree_id ITEM) IS
       TYPE pl_table_group_names IS
          TABLE OF VARCHAR(120)
          INDEX BY BINARY_INTEGER;
   TYPE pl_table_group_id IS
          TABLE OF NUMBER(6)
          INDEX BY BINARY_INTEGER;
       htree             ITEM;
       work_gr_names     pl_table_group_names;
       work_gr_id        pl_table_group_id;
       vn_group          INTEGER;
       vn_group_id       INTEGER;
       vn_member_begin   INTEGER;
       vn_member_count   INTEGER;
       v_new_node_root   FTREE.NODE;
       v_new_node_group  FTREE.NODE;
       v_new_node_member FTREE.NODE;
       vc_root_label     VARCHAR2(80);
      
       CURSOR rila_groups IS
          SELECT id,group_name,group_director_name  FROM rila_group;
          vc_rila_group rila_groups%ROWTYPE;
          
       CURSOR rila_employees IS
          SELECT id, rila_id|| '        '|| given_name||' ' || second_name ||' '|| surname AS name
          FROM employee
          WHERE     service_status = :service_status
                AND employee.rila_group = vn_group_id
          ORDER BY rila_id;
       vc_rila_employee rila_employees%ROWTYPE;
      
BEGIN
 
   -- Register ALL Rila group - Group_Names and Id
   OPEN rila_groups;
   vn_group := 0;
   LOOP
           FETCH rila_groups INTO vc_rila_group;
           EXIT WHEN  rila_groups%NOTFOUND;
          vn_group := vn_group + 1;
          work_gr_names(vn_group) := vc_rila_group.group_name;
          work_gr_id(vn_group) := vc_rila_group.id;
   END LOOP;
   CLOSE rila_groups;
   
   
    -- Delete the existing tree (if any)
    -- Ftree.ROOT_NODE is an undocumented constant pointing the Root node of the tree
    Ftree.Delete_Tree_Node(p_tree_id,  Ftree.ROOT_NODE);
   
    -- Make the Root Node "Rila Solutions AD"
     
    vc_root_label :=  'RILA SOLUTIONS AD';
    IF    :service_status = '1' THEN  vc_root_label := vc_root_label || ' - list of candidates';
    ELSIF :service_status = '2' THEN  vc_root_label := vc_root_label || ' - list of employees';
    ELSIF :service_status = '3' THEN  vc_root_label := vc_root_label || ' - list of released';
    END IF;

                   v_new_node_root := Ftree.Add_Tree_Node(
                                        p_tree_id,
                                        Ftree.ROOT_NODE,
                                        Ftree.PARENT_OFFSET,
                                        Ftree.LAST_CHILD,
                                        Ftree.EXPANDED_NODE,
                                        vc_root_label,
                                        NULL,
                                        NULL);
                
   -- Add nodes to the Hierarchical Tree - Subgroup Nodes  
   FOR i IN  1..vn_group LOOP
               -- Add parent node - the name of the Rila Group
               /*
               v_new_node_group := Ftree.Add_Tree_Node(
                                        p_tree_id,
                                        Ftree.ROOT_NODE,
                                        Ftree.PARENT_OFFSET,
                                        Ftree.LAST_CHILD,
                                        Ftree.EXPANDED_NODE,
                                        work_gr_names(i),
                                        NULL,
                                        work_gr_names(i));                                  
                                     
          */
                         v_new_node_group := Ftree.Add_Tree_Node(
                                        p_tree_id,
                                        v_new_node_root,
                                        Ftree.PARENT_OFFSET,
                                        Ftree.LAST_CHILD,
                                        Ftree.EXPANDED_NODE,
                                        work_gr_names(i),
                                        NULL,
                                        work_gr_names(i));
       -- Add all sibling nodes - Employees Member of the Subgroup                                
       vn_group_id := work_gr_id(i);
       FOR k IN rila_employees LOOP
           v_new_node_member := Ftree.Add_Tree_Node(
                                        p_tree_id,
                                        v_new_node_group,
                                        Ftree.PARENT_OFFSET,
                                        Ftree.LAST_CHILD,
                                        Ftree.EXPANDED_NODE,
                                        k.name,
                                        NULL,
                                        TO_CHAR(k.id));
       
       END LOOP;


   END LOOP;
   
   -- Expand the ROOT node of the hierarchical tree  
   FTREE.SET_TREE_NODE_PROPERTY (p_tree_id, v_new_node_root, Ftree.NODE_STATE, Ftree.EXPANDED_NODE);
   
   --Ftree.Set_Tree_Node_Property(htree, node, Ftree.NODE_STATE, Ftree.EXPANDED_NODE);
   vn_member_begin := vn_group + 1;
         
  EXCEPTION
      WHEN OTHERS THEN
        CLOSE rila_groups;
        CLOSE rila_employees;
END POPULATE_TREE;  -- End Procedure POPULATE_TREE
 


PROCEDURE Open_Employee_Form (p_tree_id ITEM) IS  

   node_label    VARCHAR2(100);
   node_value    VARCHAR2(10);
   node_depth    VARCHAR2(1);  
       list_id   ParamList;
       list_name VARCHAR2(10) := 'param_list';
BEGIN
      
   -- Find the DEPTH of the node clicked on.
   node_depth := Ftree.Get_Tree_Node_Property(p_tree_id, :SYSTEM.TRIGGER_NODE, Ftree.NODE_DEPTH);
   
   --MESSAGE(node_depth || ' ' || node_value ||' '|| node_label);
   --PAUSE;

     
     -- only nodes with depth 3 correspond to employees
     -- depth 3 corresponds to groups
     -- depth 1 corresponds to RILA SOLUTION
     IF  node_depth  = '3' THEN
           
             -- Find the VALUE of the node clicked on.
        node_value := Ftree.Get_Tree_Node_Property(p_tree_id, :SYSTEM.TRIGGER_NODE, Ftree.NODE_VALUE);
        -- Find the LABEL of the node clicked on.
        node_label := Ftree.Get_Tree_Node_Property(p_tree_id, :SYSTEM.TRIGGER_NODE, Ftree.NODE_LABEL);
        /*
            ** Create a parameter list named "param_list"
             */
        list_id := Get_Parameter_List(list_name);
        IF NOT Id_Null(list_id) THEN
                    Destroy_Parameter_List(list_id);
            END IF;
       
            list_id := Create_Parameter_List(list_name);
          
             /*
             ** Add parameter to the list to pass values for each
             ** user-defined parameters defined in the target form; for each
             ** parameter, specify its key, type (text or data), and value
             */
               Add_Parameter(list_id, 'PROCESS_TYPE',TEXT_PARAMETER,'EDIT');
               Add_Parameter(list_id, 'EMPLOYEE#',TEXT_PARAMETER,TO_NUMBER(node_value));
               Add_Parameter(list_id, 'EMPLOYEE_SERVICE_STATUS',TEXT_PARAMETER,:SERVICE_STATUS);
               Add_Parameter(list_id, 'WEB_or_LAN',TEXT_PARAMETER,:DATA.WEB_or_LAN);
 
 
               -- now open the form using the created parameter list
               OPEN_FORM('staff_new',ACTIVATE,SESSION,list_id);
     END IF;

END Open_Employee_Form; -- End Procedure Open_Employee_Form


 
PROCEDURE Colapse_All_Nodes (p_tree_id ITEM) IS
   node ftree.node;
   state varchar2(30);
   node_label varchar2(80);

BEGIN

   -- Get the root node
   node := Ftree.Find_Tree_Node(p_tree_id,'Management',Ftree.FIND_NEXT,Ftree.NODE_LABEL, Ftree.ROOT_NODE);

   --node_label := Ftree.Get_Tree_Node_Property(p_tree, node, Ftree.NODE_LABEL);
   --MESSAGE(node_label);
   --PAUSE;      

   -- collapse the node if it is expanded
   WHILE NOT Ftree.ID_NULL(node) LOOP
      state := Ftree.Get_Tree_Node_Property(p_tree_id, node, Ftree.NODE_STATE);
      IF state = Ftree.EXPANDED_NODE THEN
          Ftree.Set_Tree_Node_Property(p_tree_id, node, Ftree.NODE_STATE, Ftree.COLLAPSED_NODE);
      END IF;

      node := Ftree.Find_Tree_Node(p_tree_id, '', ftree.find_NEXT,Ftree.NODE_LABEL,'', node);

   END LOOP;
END colapse_all_nodes;
   
   

PROCEDURE Expand_All_Nodes (p_tree_id ITEM) IS
   node ftree.node;
   state varchar2(30);
   node_label varchar2(80);

BEGIN

-- Get the root node
   node := Ftree.Find_Tree_Node(p_tree_id,'RILA SOLUTIONS',Ftree.FIND_NEXT,Ftree.NODE_LABEL, Ftree.ROOT_NODE);

   --node_label := Ftree.Get_Tree_Node_Property(htree, node, Ftree.NODE_LABEL);
   --MESSAGE(node_label);
   --PAUSE;      

   -- expand the node if it is collapsed
   WHILE NOT Ftree.ID_NULL(node) LOOP
      state := Ftree.Get_Tree_Node_Property(p_tree_id, node, Ftree.NODE_STATE);
      IF state = Ftree.COLLAPSED_NODE THEN
         Ftree.Set_Tree_Node_Property(p_tree_id, node, Ftree.NODE_STATE, Ftree.EXPANDED_NODE);
      END IF;
      node := Ftree.Find_Tree_Node(p_tree_id, '', ftree.find_NEXT,Ftree.NODE_LABEL,'', node);
   END LOOP;
END Expand_All_Nodes;
0
 

Author Comment

by:zeeshan21m
ID: 7092791
Thanks a lot Man
0

Featured Post

PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

Join & Write a Comment

Have you ever had to make fundamental changes to a table in Oracle, but haven't been able to get any downtime?  I'm talking things like: * Dropping columns * Shrinking allocated space * Removing chained blocks and restoring the PCTFREE * Re-or…
How to Unravel a Tricky Query Introduction If you browse through the Oracle zones or any of the other database-related zones you'll come across some complicated solutions and sometimes you'll just have to wonder how anyone came up with them.  …
This video explains at a high level about the four available data types in Oracle and how dates can be manipulated by the user to get data into and out of the database.
This video shows how to recover a database from a user managed backup

746 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

10 Experts available now in Live!

Get 1:1 Help Now