cancel
Showing results for 
Search instead for 
Did you mean: 

How to add an action on a cell in a dynamic generated node

michael_fallenbchel
Active Participant
0 Kudos

Hi experts,

I created a dynamic node in my view, with different number of columns, always just one row.

No I want to have an action on clicking one of the cells (contains images).

I tried the follwing in my modifyview:

METHOD wddomodifyview .

  DATA: l_root TYPE REF TO cl_wd_uielement_container,
        l_node TYPE REF TO if_wd_context_node.

  DATA:  lr_table TYPE REF TO cl_wd_table,
         lr_column TYPE REF TO cl_wd_table_column,
         lr_columns TYPE TABLE OF REF TO cl_wd_table_column WITH DEFAULT KEY,
         l_layout TYPE REF TO cl_wd_layout_data.

  DATA: lines TYPE i.
  DATA: column TYPE string,
        index TYPE string.

  IF first_time = abap_true.
    l_root ?= view->get_root_element( ).
    l_node = wd_context->get_child_node( 'PIC_PACK' ).

    lr_table = cl_wd_dynamic_tool=>create_table_from_node(
                      ui_parent = l_root
                      table_id = 'PIC_PACK'
                      node = l_node ).
      lr_table->SET_VISIBLE_ROW_COUNT( '1 ').

    lr_columns = lr_table->get_columns( ).

    DESCRIBE TABLE lr_columns LINES lines.

    DO lines TIMES.
      lr_column ?= lr_table->get_column( index = sy-index ).


      DATA: lr_image   TYPE REF TO cl_wd_image.
      column = 'PIC_PACK.PIC_&_PACK'.
      index = sy-index.
      REPLACE '&' IN column WITH index.
      CONDENSE column NO-GAPS.
      lr_image = cl_wd_image=>new_image( bind_source = column
                                          height     = '40' ).
      lr_column->set_table_cell_editor( the_table_cell_editor = lr_image ).
      lr_column->set_on_action( 'CLICK_PIC_PACK' ).
    ENDDO.

  ENDIF.

ENDMETHOD.

This way I reach to call an action on clicking on the columns-header.

But I want it on clicking on the cell/image.

Could someone give me an example?

Thanks

Michael

One additinoal qeustein - How to place the generated tab somewhere on the View? Now it's just placed at the bottom...

Accepted Solutions (0)

Answers (1)

Answers (1)

michael_fallenbchel
Active Participant
0 Kudos

One additinoal qeustein - How to place the generated tab somewhere on the View? Now it's just placed at the bottom...

This qustion is answered - I just have to change the root element for cl_wd_dynamic_tool=>create_table_from_node

michael_fallenbchel
Active Participant
0 Kudos

Just got the answer on myself!

I made a dynmic ALV with LinkToAction in each cell...that works...