cancel
Showing results for 
Search instead for 
Did you mean: 

WD table dynamically change field to read only

Former Member
0 Kudos

Hello!

I am using WebDynpro table element to display a... well table.

I have one column with checkboxes. They are either checked or empty based on database table ( ' ' or 'X'). I have next column where each field is a dropdown menu. Now i have to make the dropdown read only or editable based on checkbox status.

So if the checkbox is empty the next field (dropdown menu) should be read only, and other way around.

Can this be done with table element or should i use UIcontainer for ALV?

Accepted Solutions (1)

Accepted Solutions (1)

amy_king
Active Contributor
0 Kudos

Hi Niklavs,

You can use the Checkbox element's onToggle event to set the DropDown element enabled or not enabled. In your 0..n context node that is the data source for the Table, create a new context attribute, e.g., DROPDOWN_ENABLED, of type WDY_BOOLEAN and bind this attribute to the DropDown field's enabled property. In your action method for onToggle, set the value of the context attribute to either true or false.

(BTW, you may want to move this discussion to the Web Dynpro ABAP community.)

Cheers,

Amy

Former Member
0 Kudos

Thank you, this got me on the right track and now it is working as intended.

Created WDY_BOOLEAN atribute READ_ONLY. When filling the table the READ_ONLY is set to true or false based on checkbox status. And on checkbox toggle it is also alteranted. The readOnly property is bound to READ_ONLY atribute.

Answers (2)

Answers (2)

Former Member
0 Kudos

Hi Niklavs,

In Normal Table we can achieve this..

Create two Attributes in Same Node which is your table is bind. Like ENABLE of type WDY_BOOLEAN

DISABLE of type WDY_BOOLEAN.

Bind ENABLE to read_only property of all attributes in that node except CHECKBOX attribute.

Bind DISABLE to dropdown attribute readlonly property..

In doint method set these as per your requirement.

In on_toggle of that check box write below trype of code..

Please create on parameter context_element of type IF_WD_CONTEXT_ELEMENT.

  DATA lo_nd_n_table TYPE REF TO if_wd_context_node.
  DATA lo_el_n_table TYPE REF TO if_wd_context_element.
  DATA ls_n_table TYPE wd_this->Element_n_table.

* navigate from <CONTEXT> to <N_TABLE> via lead selection
  lo_nd_n_table = wd_context->get_child_node( name = wd_this->wdctx_n_table ).

* get element via lead selection
  lo_el_n_table = lo_nd_n_table->get_element( ).

* get all declared attributes
  context_element->get_static_attributes(
    IMPORTING
      static_attributes = ls_n_table ).

  IF ls_n_table-check IS NOT INITIAL.
    ls_n_table-disable = abap_false.
  ELSE.
    ls_n_table-disable = abap_true.
  ENDIF.

Finally, on check of check box that row of dropdown is in disable, if uncheck it is in enable.

Cheers,

Kris.



Former Member
0 Kudos

hello,

Did you try the SET_READ_ONLY_FIELDNAME() method? Using this method you can bind the read only property of the column to context attribute.

1. Create a boolean attribute in the context node that is passed to the ALV

2. For all the ALV Columns ( lr_dropdown_by_key etc). call the method  

    SET_READ_ONLY_FIELDNAME( <AttributeName> )

3. In the Button event handler, for the selected row element, set this attribute property to abap_true.

best regards,

swanand