Code: Alles auswählen.
"Eventhandler-Klasse
CLASS lcl_tree_event_receiver DEFINITION.
PUBLIC SECTION.
METHODS:
item_double_click
FOR EVENT item_double_click OF cl_gui_alv_tree
IMPORTING fieldname node_key, "coulmnName; index in Table
node_double_click
FOR EVENT node_double_click OF cl_gui_alv_tree
IMPORTING node_key.
ENDCLASS.
CLASS lcl_tree_event_receiver IMPLEMENTATION.
METHOD item_double_click.
"do something.......
ENDMETHOD.
METHOD node_double_click.
"do something.......
ENDMETHOD.
ENDCLASS.
"...
Code: Alles auswählen.
"data deklarationen + tree aufbau + eventhandler setzen
DATA: g_tree TYPE REF TO cl_gui_alv_tree,
g_handler TYPE REF TO lcl_tree_event_receiver,
g_tree TYPE REF TO cl_gui_alv_tree,
gt_fieldcat TYPE lvc_t_fcat,
g_custom_container TYPE REF TO cl_gui_custom_container.
CREATE OBJECT g_custom_container
EXPORTING
container_name = 'TREE'
EXCEPTIONS
cntl_error = 1
cntl_system_error = 2
create_error = 3
lifetime_error = 4
lifetime_dynpro_dynpro_link = 5
OTHERS = 6.
CREATE OBJECT g_tree
EXPORTING
parent = g_custom_container
node_selection_mode = cl_gui_column_tree=>node_sel_mode_multiple
item_selection = space
no_html_header = 'X'
EXCEPTIONS
cntl_error = 1
cntl_system_error = 2
create_error = 3
lifetime_error = 4
illegal_node_selection_mode = 5
failed = 6
illegal_column_name = 7
OTHERS = 8.
"create hierarchy header
PERFORM build_hierarchy_header CHANGING g_hierarchy_header.
"set tree
CALL METHOD g_tree->set_table_for_first_display
EXPORTING
is_hierarchy_header = g_hierarchy_header
CHANGING
it_outtab = gt_log
it_fieldcatalog = gt_fieldcat
.
"create hierarchy
PERFORM create_hierarchy.
CREATE OBJECT g_handler.
SET HANDLER g_handler->item_double_click FOR g_tree.
SET HANDLER g_handler->node_double_click FOR g_tree.
Code: Alles auswählen.
"set events for the tree
CALL METHOD g_tree->get_registered_events
IMPORTING
events = lt_events.
l_event-eventid = cl_gui_column_tree=>eventid_node_double_click.
APPEND l_event TO lt_events.
l_event-eventid = cl_gui_column_tree=>eventid_item_double_click.
APPEND l_event TO lt_events.
CALL METHOD g_tree->set_registered_events
EXPORTING
events = lt_events
EXCEPTIONS
cntl_error = 1
cntl_system_error = 2
illegal_event_combination = 3.
CREATE OBJECT g_handler.
SET HANDLER g_handler->item_double_click FOR g_tree.
SET HANDLER g_handler->node_double_click FOR g_tree.