Skip to Content
0
Jun 11, 2018 at 04:13 PM

Dynamic buttons arranged in rows

117 Views Last edit Jun 11, 2018 at 04:19 PM 2 rev

Hello. My task is to make all entries from an internal table have their own button each with the name as one of the attributes of the record(e.g. ITEM_NAME). I want to arrange 3 buttons of these per row. I need a solution that does this dynamically and I am stuck since I don't know how to create dynamically other transparent containers for the rows, since I thought that would help me when arranging the items in rows. I managed to arrange them in one row, however I'm not sure how to approach the rows arrangement. I put the code that works in a single row. Thanks in advance!

IF lr_caption IS INITIAL.

            CALL METHOD cl_wd_caption=>new_caption( EXPORTING text = 'Our Products' RECEIVING control = lr_caption ).

            lr_matrix = cl_wd_matrix_head_data=>new_matrix_head_data( lr_caption ).

            lr_caption->set_layout_data( lr_matrix ).

            CALL METHOD lo_container->add_child(

              EXPORTING

                index     = 1

                the_child = lr_caption ).

          ENDIF.

          lv_item_name = ls_items-name.

          lv_image = ls_items-img_source.

          CALL METHOD cl_wd_button=>new_button( EXPORTING image_source = lv_image text = lv_item_name enabled = 'X' on_action = 'ITEM_VIEW' RECEIVING control = lr_button ).



          CLEAR lr_matrix.

          lr_matrix = cl_wd_matrix_data=>new_matrix_data(  lr_button ).



          lr_button->set_layout_data( lr_matrix ).



          CALL METHOD lo_container->add_child(

            EXPORTING

              index     = 2

              the_child = lr_button ).



          ls_buttons-id = lr_button->get_id( ).

          ls_buttons-name = lr_button->get_text( ).

          APPEND ls_buttons TO lt_buttons.