6 Replies Latest reply: Aug 20, 2013 8:54 AM by user12213760 RSS

    TREE - EXPAND SELECTED NODE

    544725
      Hello,

      I have a tree that has 4 buttons:

      [+ +] = expand all tree nodes (working fine)
      [  + ] = expand all nodes of the SELECTED node (I need help here)
      [  -  ] = collapse all nodes of the SELECTED node (I need help here)
      [ - - ] = collapse all tree nodes (working fine)


      This is the code that I am using to expand all tree nodes [+ +]

      ----------------------------------------------------------------------------------------------
      DECLARE
      node ftree.node;
      v_htree ITEM;
      state varchar2(30);
      BEGIN
      -- Find the tree itself.
      v_htree := Find_Item('my_tree');

      -- Find the root node of the tree.
      node := Ftree.Find_Tree_Node(v_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(v_htree, node, Ftree.NODE_STATE);
      IF state = Ftree.COLLAPSED_NODE THEN
      Ftree.Set_Tree_Node_Property(v_htree, node, Ftree.NODE_STATE, Ftree.EXPANDED_NODE);
      END IF;
      node := Ftree.Find_Tree_Node(v_htree, '', ftree.find_NEXT,Ftree.NODE_LABEL,'', node);
      END LOOP;
      END;
      ----------------------------------------------------------------------------------------------

      As I said before, now I need help to expand/collapse all nodes of the SELECTED node.

      I am getting the selected node value using the "When-Tree-Node-Selected", but after that I don't know how to continue.

      Can anyone help me?

      Thanks!
        • 1. Re: TREE - EXPAND SELECTED NODE
          544725
          no one?
          • 2. Re: TREE - EXPAND SELECTED NODE
            544725
            ???
            • 3. Re: TREE - EXPAND SELECTED NODE
              221488
              The same code above should work but the start node is the node referenced by the system variable :system.trigger_node.
              • 4. Re: TREE - EXPAND SELECTED NODE
                OraMol
                It should work provided you have populated the whole tree.
                If you are populating it incrementally in WHEN-TREE-NODE-ACTIVATED trigger then it will not work.
                • 5. Re: TREE - EXPAND SELECTED NODE
                  Sarah
                  hi

                  1....when-button-pressed trigger.

                  code

                  Implose_Tree ;

                  2.-------

                  PROCEDURE Implose_tree IS
                  node ftree.node;
                  htree ITEM;
                  state varchar2(30);

                  BEGIN
                  -- Search the tree identifiant --
                  htree := Find_Item('b_tree.tree');


                  -- Search the root --
                  node := Ftree.Find_Tree_Node(htree, '');


                  -- Collapse all nodes --
                  WHILE NOT ftree.ID_NULL(node) LOOP
                  state := Ftree.Get_Tree_Node_Property(htree, node, Ftree.NODE_STATE);
                  IF state = Ftree.EXPANDED_NODE THEN
                  Ftree.Set_Tree_Node_Property(htree, node, Ftree.NODE_STATE, Ftree.COLLAPSED_NODE);
                  END IF;
                  node := Ftree.Find_Tree_Node(htree, '', Ftree.FIND_NEXT,Ftree.NODE_LABEL, '', node);


                  END LOOP;
                  END;


                  3------.when-button-pressed trigger.

                  Explose_Tree ;


                  4.--------------
                  PROCEDURE explose_tree IS

                  node ftree.node;
                  htree ITEM;
                  state varchar2(30);

                  BEGIN

                  -- Search the tree identifiant --
                  htree := Find_Item('b_tree.tree');

                  -- Search the root --
                       node := Ftree.Find_Tree_Node(htree, '');

                  -- Expand all nodes --
                  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, '', ftree.find_NEXT,Ftree.NODE_LABEL,'', node);

                  END LOOP;

                  END;

                  sarah

                  Edited by: SarahSarahSarah on Sep 24, 2009 3:45 AM
                  • 6. Re: TREE - EXPAND SELECTED NODE
                    user12213760

                    It's a really old topic but it's on the first page of Google results, so for people like me looking for the solution, this is the answer...

                    The code is right, however, to expand/collapse only the nodes of the SELECTED node (and not ALL nodes of the tree), you should add in the loop condition a test on node level.

                     

                    DECLARE

                     

                      node ftree.node;
                      v_htree ITEM;
                      state varchar2(30);
                      starting_node_level  NUMBER;
                      current_node_level NUMBER;

                     

                    BEGIN

                      -- Find the tree itself.
                      v_htree := Find_Item('my_tree');

                    -- Find the root node of the tree.
                      node := Ftree.Find_Tree_Node(v_htree, '');     -- OR node := :SYSTEM.TRIGGER_NODE; OR node := :SYSTEM.RIGHT_MOUSE_TRIGGER_NODE;
                      starting_node_level  := FTREE.GET_TREE_NODE_PROPERTY(v_htree, node, FTREE.NODE_DEPTH);
                      current_node_level := -1;
                     
                    -- Loop through all nodes and expand each one if it is collapsed.
                      WHILE (NOT Ftree.ID_NULL(node) AND current_node_level != starting_node_level ) LOOP
                        state := Ftree.Get_Tree_Node_Property(v_htree, node, Ftree.NODE_STATE);
                        IF state = Ftree.COLLAPSED_NODE THEN
                              Ftree.Set_Tree_Node_Property(v_htree, node, Ftree.NODE_STATE, Ftree.EXPANDED_NODE);
                        END IF;
                        node := Ftree.Find_Tree_Node(v_htree, '', ftree.find_NEXT,Ftree.NODE_LABEL,'', node);
                        IF FTREE.ID_NULL(node) = FALSE THEN
                               current_node_level := FTREE.GET_TREE_NODE_PROPERTY(v_htree, node, FTREE.NODE_DEPTH);
                        END IF;
                      END LOOP;

                     

                    END;