You can populate a hierarchical tree with values contained in a Record Group or Query Text by using the following Built-in subprogram:
Note:All Built-ins are located in the FTREE Built-in package.
-- 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;
-- Tree Node Expansion Example
--
-- This code will expand all nodes in a tree.
DECLARE
htree ITEM;
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;