Application Development and Automation Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 
Read only

Expand node event cl_gui_alv_tree

Former Member
0 Likes
2,151

Hi all,

I have an ALV_TREE and I want to do one thing when you expand a node, but I do not know how to control it.

I created the method for the double_click event but I do not know how to do it for the event EXPAND_NC. I do not work so well that double_click.

Do you know how?

What is the event I should use?

Thanks in advance.

Hi all,

I have an ALV_TREE and I want to do one thing when you expand a node, but I do not know how to control it.

I created the method for the double_click event but I do not know how to do it for the event EXPAND_NC. I do not work so well that double_click.

Do you know how?

What is the event I should use?

Thanks in advance.

3 REPLIES 3
Read only

Former Member
0 Likes
1,238

EXPAND_NC is the event

NODE_DOUBLE_CLICK handler to be used

Read only

0 Likes
1,238

Thanks Gayathri, but I can not make it work.

This is part of my code;

*&---------------------------------------------------------------------*
* Events class;
*&---------------------------------------------------------------------*
CLASS lcl_tree_event_receiver DEFINITION.

  PUBLIC SECTION.
    METHODS node_double_click
      FOR EVENT node_double_click OF cl_gui_alv_tree
      IMPORTING node_key.
    METHODS item_double_click
      FOR EVENT item_double_click OF cl_gui_alv_tree
      IMPORTING node_key.
    METHODS expand_node
      FOR EVENT EXPAND_NC OF cl_gui_alv_tree
      IMPORTING node_key.

ENDCLASS.                    "lcl_tree_event_receiver DEFINITION
*&---------------------------------------------------------------------*
*&   Class (Implementation)lcl_tree_event_receive*
*&---------------------------------------------------------------------*
*        Text
*----------------------------------------------------------------------*

CLASS lcl_tree_event_receiver IMPLEMENTATION.

  METHOD node_double_click.
    PERFORM trigger_dblclick_event USING node_key.
  ENDMETHOD.                    "handle_node_double_click

  METHOD item_double_click.
    PERFORM trigger_dblclick_event USING node_key.
  ENDMETHOD.                    "handle_node_double_click

  METHOD expand_node.
    PERFORM p_expand_node USING node_key.
  ENDMETHOD.

form REGISTER_EVENTS .

* Event registration: tell ALV Tree which events shall be passed
* from frontend to backend.
  DATA: lt_events TYPE cntl_simple_events,
        l_event TYPE cntl_simple_event,
        l_event_receiver TYPE REF TO lcl_tree_event_receiver.

* Frontend registration:  get already registered tree events
  CALL METHOD g_alv_tree->get_registered_events
    IMPORTING
      events = lt_events.

* Frontend registration: add additional event ids
  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.

  l_event-eventid = cl_gui_column_tree=>EVENTID_EXPAND_NO_CHILDREN.
  APPEND l_event TO lt_events.


* Frontend registration: provide new event table to alv tree
  CALL METHOD g_alv_tree->set_registered_events
    EXPORTING
      events                    = lt_events
    EXCEPTIONS
      cntl_error                = 1
      cntl_system_error         = 2
      illegal_event_combination = 3.
  IF sy-subrc <> 0.
    MESSAGE x208(00) WITH 'ERROR'.                          "#EC NOTEXT
  ENDIF.

* Register events on backend (ABAP Objects event handling)
  CREATE OBJECT l_event_receiver.
  SET HANDLER l_event_receiver->node_double_click FOR g_alv_tree.
  SET HANDLER l_event_receiver->item_double_click FOR g_alv_tree.
  SET HANDLER l_event_receiver->expand_node FOR g_alv_tree.

endform.                    " REGISTER_EVENTS

I put a break-point in trigger_dblclick_event and p_expand_node performs. The program stops at the break of the double click but not for an expanded node

What am I doing wrong?

Read only

Former Member
1,238

the name of the event explain this;

expand_NO_CHILDREN.

This only work with nodes without childrens.

In order to display the icon of expand in a node without children in the call of method add_node, pass this;

ls_node_layout-EXPANDER = 'X'.