cancel
Showing results for 
Search instead for 
Did you mean: 

Dynamic binding for input field properties

Former Member
0 Kudos

Hi,

I have to bind the enabled property of input field dynamically. I can not bind the property with any attribute.

PLease suggest, and also give some dummy program if possible.

Regards,

Pankaj Aggarwal

Accepted Solutions (0)

Answers (4)

Answers (4)

Former Member
0 Kudos

Hi Pankaj,

Declare one attribute 'BOOLEAN' in context. Bind this boolean attribute to your input field, enabled Property.

Then write this code.

  DATA lo_el_context TYPE REF TO if_wd_context_element.
  DATA ls_context TYPE wd_this->element_context.
  DATA lv_boolean LIKE ls_context-boolean.
* get element via lead selection
  lo_el_context = wd_context->get_element(  ).

  lv_boolean = 'X'.
  
* get single attribute
  lo_el_context->set_attribute(
    EXPORTING
      name =  `BOOLEAN`
      value = lv_boolean ).

Regards

Vishnu Gupta

Former Member
0 Kudos

Hi you can bind the ready only property with an attribute dynamically as follows


Create an attribute say 'EDITABLE' type boolean

lt_columns = l_column_settings->get_columns( )  .

  LOOP AT lt_columns INTO ls_columns    .
  CASE ls_columns-id.

  WHEN 'COLUMN'.
* Create Editable cell
        DATA: l_input_field TYPE REF TO cl_salv_wd_uie_input_field.

        CREATE OBJECT l_input_field
          EXPORTING
            value_fieldname = ls_columns-id.
        ls_columns-r_column->set_cell_editor( l_input_field ) .

" binding the attribute to the read only property
        l_input_field->SET_READ_ONLY_FIELDNAME( 'EDITABLE' ).

ENDCASE.

Former Member
0 Kudos

Hi,

If you cannot bind the property with an attribute i suppose then that, you are also creating the Nodes and Attributes dynamically...?

uday_gubbala2
Active Contributor
0 Kudos

Hi Pankaj,

I have a context node by name NODE & 2 attributes under it. One is for binding to the input field and the other attribute ( name ENABLED) is of type WDY_BOOLEAN. I use this attribute for controlling the editability of my input field. I specify a default value of '' i.e, readonly for this. (Check the domain values for WDUI_BOOLEAN) Now I create a button and within this button action handler I want to toggle between the input fields readonly & editable statuses. Check the code snippet below.

Regards,

Uday

method ONACTIONTOGGLE_ENABLED .
  data: wd_node type ref to if_wd_context_node,
        lv_value type wdY_boolean.

  wd_node = wd_context->get_child_node( name = 'NODE' ).

***  Read the current value in context attribute ENABLED
  wd_node->get_attribute( exporting name  = 'ENABLED'
                          importing value = lv_value ).
*** Toggle between values '' & X to toggle between the readonly & editable states of the inputfield
  if lv_value = ''.
    wd_node->set_attribute( exporting name  = 'ENABLED'
                                      value = 'X' ).
  else.
    wd_node->set_attribute( exporting name  = 'ENABLED'
                                      value = '' ).
  endif.
endmethod.