
This section lists the functions that are specific to the column tree.
The process described here is an extension of the general process for using controls that is specific to the simple tree. It does not contain all of the steps required to produce a valid instance of the control.
The program extracts are examples that do not necessarily illustrate all of the features of the control. For precise information, refer to the reference section of this documentation.
Creating the Instance
Creating the InstanceDefine a reference variable for the column tree:
DATA column_tree TYPE REF TO cl_gui_column_tree.
Define a work area for the hierarchy heading by referring to the structure treev_hhdr .
DATA hierarchy_header TYPE treev_hhdr.
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.
Create an instance of the SAP Tree:
CREATE OBJECT column_tree
EXPORTING parent = container
node_selection_mode = node_selection_mode
hide_selection = hide_selection
item_selection = item_selection
hierarchy_column_name = hierarchy_column_name
hierarchy_header = hierarchy_header
EXCEPTIONS lifetime_error = 1
cntl_system_error = 2
create_error = 3
illegal_node_selection_mode = 4
failed = 5
illegal_column_name = 6.
Register the Events
Register the EventsRegister the events for the column tree. The control supports the following events:
|
Event name |
Description |
|---|---|
|
NODE_DOUBLE_CLICK |
User double-clicked a node |
|
EXPAND_NO_CHILDREN |
User expanded a node that has no children |
|
SELECTION_CHANGED |
Selected node has changed |
|
NODE_CONTEXT_MENU_REQUEST |
User requested a context menu with the cursor positioned on 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 requested a context menu with the cursor positioned on the heading |
|
HEADER_CONTEXT_MENU_SELECT |
User selected an entry from the context menu |
|
ITEM_KEYPRESS |
User pressed a key while an entry was selected. |
|
NODE_KEYPRESS |
User pressed a key while an entry was selected. |
|
HEADER_CLICK |
User clicked 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
Insert nodes in the tree. To do this, first fill a node table and an item table, then pass them to the control using the add_nodes_and_items method.
CALL METHOD column_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 ).
Destroying the Control
Destroying the ControlDestroy the custom control at the frontend. If you no longer need the control container, release it as well:
CALL METHOD column_tree->free.
If you are working with the lifetime management , you do not need to worry about destroying the control at the frontend yourself. It is done automatically by the system instead.
Delete the reference variables to the simple tree and the control container.
FREE column_tree.