Using the List Tree
Use
This section lists the functions that are specific to the list tree.
Prerequisites
The process described here is an extension of the general process for using controls that is specific to the list tree. It does not contain all of the steps required to produce a valid instance of the control.
Process
Creating the Instance
-
Define a reference variable for the list tree:
DATA list_tree TYPE REF TO cl_gui_list_tree.
-
If you want to create a heading for the tree, you must create a work area for the hierarchy heading with reference to the structure treev_hhdr and one for the list heading with reference to the structure treev_lhdr:
DATA hierarchy_header TYPE treev_hhdr. DATA list_header type treev_lhdr.
-
Fill the work area for the hierarchy heading. You can set the width (width and width_pix), the text (heading), an icon (t_image), and a tool tip (tooltip). There are also methods that allow you to change these attributes later on.
hierarchy_header-heading = 'Title'. hierarchy_header-width = 30.
-
Fill the work area for the hierarchy heading. You can set the text (heading), an icon (t_image) and a tool tip (tooltip).
list_header-heading = 'List heading'.
-
Create an instance of the tree control:
CREATE OBJECT list_tree EXPORTING parent = container node_selection_mode = node_selection_mode item_selection = item_selection with_headers = with_headers hierarchy_header = hierarchy_header list_header = list_header EXCEPTIONS lifetime_error = 1 cntl_system_error = 2 create_error = 3 illegal_node_selection_mode = 4 failed = 5.
Register the Events
Register events for the list tree. The control supports the following events:
|
Event Name |
Description |
|---|---|
|
NODE_DOUBLE_CLICK |
User double-clicked a node |
|
EXPAND_NO_CHILDREN |
Node without children was expanded |
|
SELECTION_CHANGED |
The selected node has changed. |
|
NODE_CONTEXT_MENU_REQUEST |
Request of a context menu for a node |
|
NODE_CONTEXT_MENU_SELECT |
User selected an entry from the context menu |
|
DEFAULT_CONTEXT_MENU_REQUEST |
User requested a context menu with the cursor positioned on an empty space in the control |
|
DEFAULT_CONTEXT_MENU_SELECT |
User selected an entry from the context menu |
|
HEADER_CONTEXT_MENU_REQUEST |
User selected an entry from the context menu |
|
HEADER_CONTEXT_MENU_SELECT |
User selected an entry from the context menu |
|
ITEM_KEYPRESS |
User selected an entry from the context menu |
|
NODE_KEYPRESS |
User selected an entry from the context menu |
|
HEADER_CLICK |
The user clicked on a heading. |
If you set the parameter item_selection = 'X'when you created the instance, you can also react to the following events:
|
Event Name |
Description |
|---|---|
|
BUTTON_CLICK |
The user clicked an item with the class BUTTON |
|
LINK_CLICK |
The user clicked an item with the class LINK |
|
CHECKBOX_CHANGE |
The user clicked an item with the class CHECKBOX |
|
ITEM_DOUBLE_CLICK |
The user double-clicked an item |
|
ITEM_CONTEXT_MENU_REQUEST |
User requested a context menu with the cursor positioned on an item |
|
ITEM_CONTEXT_MENU_SELECT |
User selected an entry from the context menu for an item |
Using the Column Tree
Add nodes to the tree. First fill a node table and a table with the entries and copy this with the add_nodes_and_items method:
CALL METHOD list_tree->add_nodes_and_items EXPORTING node_table = node_table item_table = item_table item_table_structure_name = item_table_structure_name EXCEPTIONS failed = 1 cntl_system_error = 2 error_in_tables = 3 dp_error = 4 table_structure_name_not_found = 5.
Change existing nodes in the tree, or change the tree attributes (see Changing the Attribtues of the Control).
Query any necessary attributes of the tree and its nodes (see Finding Out the Attributes of the Control).
Removing the Control
-
Remove the custom control at the front end. If you do not need the control container any more, you remove it:
CALL METHOD list_tree->free.
-
Delete the reference variables to the simple tress and the control container, if required.
FREE list_tree.