cancel
Showing results for 
Search instead for 
Did you mean: 

radiobtn group by index coding required

Former Member
0 Kudos

Hi,

I have a transparent container (matrix layout)in my view which has a tray containing 3 radio button group by index and another group with 3 input fields. i.e. each input field is by the side of a respective radio button.

My requirement is that on selecting a radio button the input field by its side should get enabled & the other 2 input field should remain disabled.

Can u help with the coding??

Thanks & Regards

Anurupa.

Accepted Solutions (1)

Accepted Solutions (1)

abhimanyu_lagishetti7
Active Contributor
0 Kudos

In WDDOMODIFYVIEW,

check the attribute value which is binded to the radio button group, and code as follows

data: wd_input_field type ref to cl_wd_input_field.

if attr_value = <first radio button value>.

wd_input_field ?= view->get_element( '<first input field ID>' ).

wd_input_field->set_enable( abap_true ).

elseif attr_value = <second radio button value>.

wd_input_field ?= view->get_element( '<second input field ID>' ).

wd_input_field->set_enable( abap_true ).

else.

  • the third one similar coding

endif

Abhi

Former Member
0 Kudos

Abhi thanks for ur quick response.

But this code is not giving me the desired result...it throws an error "attrib_value" not defined. and "view" not defined...and my requirement is to enable only one input field while the others should be disabled.

Just to throw a little more light on it : i have 2 nodes in my context- 1. radio with one attribute radio_btn and 2. input with three attributes inp1,inp2 and inp3.

I am new to WDA so it would be nice if u could elaborate a little more..

Thanks

Anurupa

Edited by: Anurupa Chowdhury on Jun 26, 2008 11:39 AM

Edited by: Anurupa Chowdhury on Jun 26, 2008 11:42 AM

abhimanyu_lagishetti7
Active Contributor
0 Kudos

Code it in WDDOMODIFYVIEW

data: lr_node type ref to if_wd_context_node

data: lv_radio_btn type < radio button context attribute type >

data: lr_input1 type ref to cl_wd_input_field.

data: lr_input2 type ref to cl_wd_input_field.

data: lr_input3 type ref to cl_wd_input_field.

lr_node = wd_context->get_child_node( '<Radio Button Node name>' ).

lr_node->get_attribute( exporting name = '<Radio Btn Attribute Name>'

importing value = lv_radio_btn ).

lr_input1 ?= view->get_element( '<ID of the 1st Input Field in the Layout'> ).

lr_input2 ?= view->get_element( '<ID of the 2nd Input Field in the Layout'> ).

lr_input3 ?= view->get_element( '<ID of the 3rd Input Field in the Layout'> ).

if lv_radio_btn = '1'. "value you provided for the first radio button

lr_input1->set_enable( abap_true ). " to enable first input field

lr_input2->set_enable( abap_false ). " to disable second input field

lr_input3->set_enable( abap_false ). " to disable third input field

elseif <second condition>

  • enable and disable accrodingly

endif.

Abhi

Answers (5)

Answers (5)

Former Member
0 Kudos

problem solved

Former Member
0 Kudos

Hi,

create an attribute 'enable' type wdy_boolean in context.

then bind each of the radiobutton enable property to this enable attribute.

Then based on the value of input field use

set_attribute(exporting name = 'ENABLE' value = 'X').

SEE ALSO WDR_TEST_EVENTS EXAMPLE

Former Member
0 Kudos

Thanks a lot Thomas, indeed that code works...but a little prob is that ...once i select the 2nd or 3rd radio button the respective input fields are getting enabled but the selection of radio button toggles back to the 1st radio button.

pls help.

Regards

Anurupa

abhimanyu_lagishetti7
Active Contributor
0 Kudos

Hi

Make sure the attribute binded to the radio button group is not getting changed in WDDOMODIFYVIEW or any other method

Abhi

Former Member
0 Kudos

hi padman,

i tried out the code u sent .. but it throws an error that the attribute 'input1_disabled'' could not be found.

could u pls resolve.

Thanks

Anurupa

thomas_jung
Developer Advocate
Developer Advocate
0 Kudos

>

> hi padman,

>

> i tried out the code u sent .. but it throws an error that the attribute 'input1_disabled'' could not be found.

>

> could u pls resolve.

>

> Thanks

> Anurupa

I think you need to read the solution provided a little closer. It is quite complete. It did say:

First Create 3 attributes with type CHAR1. For the 3 Input Fields bind the Property of Enabled to those 3 attributes that u have created.

You need to create the attributes in context called input1_disabled, etc. You then context bind thems to the enabled properties.

The usage of the context and binding is the recommended way of doing what you want over the other suggestions of using the WDDOMODIFYVIEW to directly interact with the UI elements. That approach in code should only be used as a last resort when needing dyanmic UI processing.

Former Member
0 Kudos

Hi Anrupa,

First Create 3 attributes with type CHAR1. For the 3 Input Fields bind the Property of Enabled to those 3 attributes that u have created.

In the Onselect Event of the Radio Button assign the Value of 'X' to the one Input Field and ' ' to another 2 Input Fields.

DATA lo_nd_radio TYPE REF TO if_wd_context_node.
  DATA lo_el_radio TYPE REF TO if_wd_context_element.
  DATA ls_radio TYPE wd_this->element_radio.
  DATA lv_text LIKE ls_radio-text.

* navigate from <CONTEXT> to <RADIO> via lead selection
  lo_nd_radio = wd_context->get_child_node( name = wd_this->wdctx_radio ).

* get element via lead selection
  lo_el_radio = lo_nd_radio->get_element(  ).


* get single attribute
  lo_el_radio->get_attribute(
    EXPORTING
      name =  `TEXT`
    IMPORTING
      value = lv_text ).


  DATA lo_el_context TYPE REF TO if_wd_context_element.

* get element via lead selection
  lo_el_context = wd_context->get_element(  ).

  if lv_text = 'Radio1'.
* Set single attribute
    lo_el_context->set_attribute(
        name =  `INPUT1_DISABLE`
        value = 'X' ).

* Set single attribute
    lo_el_context->set_attribute(
        name =  `INPUT2_DISABLE`
        value = ' ' ).

* Set single attribute
    lo_el_context->set_attribute(
        name =  `INPUT3_DISABLE`
        value = ' ' ).

  elseif lv_text = 'Radio2'.

* Set single attribute
    lo_el_context->set_attribute(
        name =  `INPUT1_DISABLE`
        value = ' ' ).

* Set single attribute
    lo_el_context->set_attribute(
        name =  `INPUT2_DISABLE`
        value = 'X' ).

* Set single attribute
    lo_el_context->set_attribute(
        name =  `INPUT3_DISABLE`
        value = ' ' ).

  elseif lv_text = 'Radio3'.

* Set single attribute
    lo_el_context->set_attribute(
        name =  `INPUT1_DISABLE`
        value = ' ' ).

* Set single attribute
    lo_el_context->set_attribute(
        name =  `INPUT2_DISABLE`
        value = ' ' ).

* Set single attribute
    lo_el_context->set_attribute(
        name =  `INPUT3_DISABLE`
        value = 'X' ).

  endif.

Regards,

Padmam.