Skip to Content

Archived discussions are read-only. Learn more about SAP Q&A

cl_gui_alv_tree no child nodes after registering event

Hey guys,

I have an uncommon problem with cl_gui_alv_tree.

My tree has 2 layers, Root and child. Both of them have layout-class  cl_gui_column_tree=>item_class_checkbox.

Everithing works fine! (without_events.jpg)

But if I register event "checkbox_change" with method SET_REGISTERED_EVENTS the childnodes disapear! (with_events.jpg)

Does anyone know a solution?

here's some code:

data; gr_alv_0200 type ref to cl_gui_alv_tree.

METHOD init_dynpro_0200.

     DATA: ls_hierarchy_header TYPE treev_hhdr.

     IF gr_cont_0200 IS INITIAL.

       CREATE OBJECT gr_cont_0200


           container_name              = 'CC200'


           cntl_error                  = 1

           cntl_system_error           = 2

           create_error                = 3

           lifetime_error              = 4

           lifetime_dynpro_dynpro_link = 5

           OTHERS                      = 6.

       IF sy-subrc <> 0.

         MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno

                    WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.



     IF gr_alv_0200 IS INITIAL.

       CREATE OBJECT gr_alv_0200


*         lifetime                    =

           parent                      = gr_cont_0200

           node_selection_mode         = cl_gui_column_tree=>node_sel_mode_single

           item_selection              = 'X'

           no_toolbar                  = 'X'

           no_html_header              = 'X'


           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.

       CHECK sy-subrc EQ 0.

       ls_hierarchy_header-heading = 'Hierarchy Header'.     "#EC NOTEXT

       ls_hierarchy_header-tooltip =

                              'This is the Hierarchy Header !'. "#EC NOTEXT

       ls_hierarchy_header-width = 100.

       ls_hierarchy_header-width_pix = ''.

        tree_create_fcat( ).

       CALL METHOD gr_alv_0200->set_table_for_first_display


           is_hierarchy_header = ls_hierarchy_header

           i_background_id     = 'ALV_BACKGROUND'


           it_outtab           = gt_treenodes

           it_fieldcatalog     = gt_fcat_0200.

       DATA: lt_events TYPE cntl_simple_events,

                 ls_event LIKE LINE OF lt_events.

       ls_event-eventid = cl_gui_column_tree=>eventid_checkbox_change.

       APPEND ls_event TO lt_events.

       CALL METHOD gr_alv_0200->set_registered_events


           events                    = lt_events


           cntl_error                = 1

           cntl_system_error         = 2

           illegal_event_combination = 3.

       SET HANDLER me->on_tree_checkbox_change FOR gr_alv_0200.



METHOD tree_add_node.

     DATA: ls_node_text TYPE lvc_value.

* set item-layout

     DATA: lt_item_layout TYPE lvc_t_layi,

           ls_item_layout TYPE lvc_s_layi.

     ls_item_layout-fieldname = gr_alv_0200->c_hierarchy_column_name.

     ls_item_layout-style   = cl_gui_column_tree=>style_intensifd_critical.

     ls_item_layout-class   = cl_gui_column_tree=>item_class_checkbox.

     ls_item_layout-editable = 'X'.

     APPEND ls_item_layout TO lt_item_layout.

* add node

     ls_node_text is_data-name.

     DATA: ls_node TYPE lvc_s_layn.

     ls_node-n_image   = space.

     ls_node-exp_image = space.

     CALL METHOD gr_alv_0200->add_node


         i_relat_node_key = iv_parent

         i_relationship   = cl_gui_column_tree=>relat_last_child

         i_node_text      = ls_node_text

         is_outtab_line   = is_data

         is_node_layout   = ls_node

        it_item_layout   = lt_item_layout


         e_new_node_key   = ev_node_id.


in my current class I've method on_tree_checkbox_change to handle the event. If the event is registered, the method gets called.

with_events.jpg (49147 B)
without_events.jpg (62780 B)

Solved by my own:

I had to implement method get_registered_events( ), append the new event to the table and call set_registered_events( ).

The table from get_registered_events( ) is already filled with events.

0 View this answer in context
Not what you were looking for? View more on this topic or Ask a question