cancel
Showing results for 
Search instead for 
Did you mean: 

Dtnamic Button description change in a table

Former Member
0 Kudos

Hi ,

I created a table dynamically. After creating a table dynamically i made one of the coloumn as button , Button text as 'Action' and

asigned 1 action to that .Now my button text in all rows coming as 'Action' .But my requirment is i want to change the text of

button on each row .

In detail : In my table on row1 button text should come as ''Row1' , On row 2 button text should come as 'Row2'.

1 . Is it possible to change the button text in row level ?

2 . Please tell me how can we do that?

Thanks in Advance ,

Vijay vorsu .

Accepted Solutions (1)

Accepted Solutions (1)

uday_gubbala2
Active Contributor
0 Kudos

Now within my WDDOMODIFYVIEW method am binding the text property of my button with the context attribute TEXT. This would result in different texts being displayed for the buttons in different rows:

METHOD wddomodifyview .
  CHECK first_time = abap_true.
  DATA: lr_table TYPE REF TO cl_wd_table,
        lr_column TYPE REF TO cl_wd_table_column,
        lr_button TYPE REF TO cl_wd_button.

  lr_table ?= view->get_element( id = 'T1' ).
  lr_column ?= lr_table->get_column( id = 'T1_PRICE' ).

  lr_button = cl_wd_button=>new_button( bind_text = 'SFLIGHT.TEXT'
                                        on_action = 'MYACTION' ).

  lr_column->set_table_cell_editor( the_table_cell_editor = lr_button  ).
ENDMETHOD.

Former Member
0 Kudos

Thnx uday . My issue got resolved..

Answers (2)

Answers (2)

uday_gubbala2
Active Contributor
0 Kudos

For example say I am displaying the data of SFLIGHT in my table. My context node name is SFLIGHT & I have another attribute by name TEXT of type STRING created under this node.

Now in the below supply function method am populating the data for my table. See the logic am using to have the buttons texts appear like BUTTON:1, BUTTON:2....

METHOD supply_data .
  DATA: wa_sflight TYPE wd_this->element_sflight,
        lt_sflight TYPE wd_this->elements_sflight,
        lv_text TYPE string.

  SELECT carrid
         connid
         fldate
         price FROM sflight INTO CORRESPONDING FIELDS OF TABLE lt_sflight.
  SORT lt_sflight BY price.
  DELETE ADJACENT DUPLICATES FROM lt_sflight COMPARING price.

  LOOP AT lt_sflight INTO wa_sflight.
    wa_sflight-text = sy-tabix.
    CONCATENATE 'Button:'
                wa_sflight-text INTO wa_sflight-text SEPARATED BY space.
    MODIFY lt_sflight FROM wa_sflight TRANSPORTING text.
    CLEAR wa_sflight.
  ENDLOOP.
  node->bind_table( new_items = lt_sflight ).
ENDMETHOD.

uday_gubbala2
Active Contributor
0 Kudos

Hi Vijay,

You can achieve this using the BIND_TEXT property of the buttons class.

1) Create another attribute of type STRING under the same node which you are using to bind to your table.

2) Now while populating the tables data (within your supply function/WDDOINIT method) also populate the corresponding texts that you would like to appear for your button.

3) Now while specifying the tables cell editor as a button bind the buttons text (using the BIND_TEXT property) to the STRING attribute created earlier.

Regards,

Uday