cancel
Showing results for 
Search instead for 
Did you mean: 

How to disable other radiobuttons by selecting one radiobutton

Former Member
0 Kudos

Hi All,

according to my requirement there will be three radiobuttons named as COPY MASS UPLOAD AUTOMATED RATE PROCESSING

if suppose user selects copyradiobutton remaining two radiobuttons should be disabled.

but according to my output if i am selecting copybutton remaining two are not been disabling. kindly correct where i have went wrong and to achieve my functionality kindly send me the steps.

to display radio buttons in output i have followed these steps my node name is ZRADIO and my attribute name is KEY. and i have used RADIOBUTTONGROUPBYKEY UI ELEMENT and for the selectedkey property ui elementi have binded this key attribute. and in wddoinint method i have written the following code.

data nodeinf type ref to if_wd_context_node_info.

data node type ref to if_wd_context_node.

node = wd_context->get_child_node( 'ZRADIO' ). "ZRADIO is the node name

nodeinf = node->get_node_info( ).

data lt_vs type table of WDR_CONTEXT_ATTR_VALUE.

data ls_vs type WDR_CONTEXT_ATTR_VALUE.

ls_vs-text = 'Copy'.

ls_vs-value = '1'.

append ls_vs to lt_vs.

ls_vs-text = 'Mass Upload'.

ls_vs-value = '2'.

append ls_vs to lt_vs.

ls_vs-text = 'Automated Rate Processing'.

ls_vs-value = '3'.

append ls_vs to lt_vs.

nodeinf->set_attribute_value_Set(

name = 'KEY' "KEY is the attribute name

value_set = lt_vs

).

Thanks & Regards,

Naveen

Accepted Solutions (1)

Accepted Solutions (1)

gill367
Active Contributor
0 Kudos

For controlling these properties like enable and read only dynamically usually the procedure is to create an attribute of type

Wdy_boolean.

so go to your context tab and there create one attribute

name = flag

type = wdy_boolean.

save it.

now go to your layout tab there click on the property enable and bind it to this attribute by clicking on the button

just beside the property.

save it. and open the eventhandler of the radiobutton group and there write the code.

wd_context->set_attribute(

name = 'FLAG'

value = abap_false

).

save it and activate.

now on selecting the radio button the group will be disabled.

thanks

sarbjeet singh

Former Member
0 Kudos

Hi sarbjeet

but if i follow the procedure as you said it is daisabling all three radiobuttons. but my requirement is suppose if user select copy remaining two should be disabled can u send me the code for this logic.

Thanks & Regards,

Naveen

gill367
Active Contributor
0 Kudos

Hi sarbjeet

but if i follow the procedure as you said it is daisabling all three radiobuttons. but my requirement is suppose if user select copy remaining two should be disabled can u send me the code for this logic.

Thanks & Regards,

Naveen

Hello Naveen.

suppose you have three radio buttons.

A ( ) B ( ) C( )

so suppose you select A now it like

A (.) B( ) C( )

now you want to disable only B and C.

now you tell me what is the use of keeping A enable. because anyways you cannot do anything with it now.

you cannot unselect it.

BUT STILL IF YOU WANT TO HAVE ONLY B and C to be disabled.

then create three attribute in the context say FLAGA, FLAGB, FLAGC.

AND binf them to enable property of the radio buttons a, b, and c.

now go to the wddoinit and write the code.

.
 wD_CONTEXT->SET_ATTRIBUTE(
  NAME = 'FLAGA'
  VALUE = ABAP_TRUE
  ).
wD_CONTEXT->SET_ATTRIBUTE(
  NAME = 'FLAGB'
  VALUE = ABAP_TRUE
  ).
wD_CONTEXT->SET_ATTRIBUTE(
  NAME = 'FLAGC'
  VALUE = ABAP_TRUE
  ).
..

then create three seperate actions for radio buttons.

a, b and c.

and write th ecode to disble the other two on selecting one radio button like as shown below .

eventhandler of A.

.
wD_CONTEXT->SET_ATTRIBUTE(
  NAME = 'FLAGB'
  VALUE = ABAP_false  ).
wD_CONTEXT->SET_ATTRIBUTE(
  NAME = 'FLAGC'
  VALUE = ABAP_false
  ).
..

similalry for B

eventhandler of B.

.
wD_CONTEXT->SET_ATTRIBUTE(
  NAME = 'FLAGA'
  VALUE = ABAP_false  ).
wD_CONTEXT->SET_ATTRIBUTE(
  NAME = 'FLAGC'
  VALUE = ABAP_false
  ).
..

and for C

eventhandler of C.

.
wD_CONTEXT->SET_ATTRIBUTE(
  NAME = 'FLAGA'
  VALUE = ABAP_false  ).
wD_CONTEXT->SET_ATTRIBUTE(
  NAME = 'FLAGB'
  VALUE = ABAP_false
  ).
..

thanks

sarbjeet singh

Former Member
0 Kudos

So in this case you need to use 3 separate Radio Buttons rather than one RadioButton Group .

Shikhil

Answers (1)

Answers (1)

sahai
Contributor
0 Kudos

HELLO NAVEEN,

you want to enable and disable the other two radio button on selection of one radio button...rite?

to do this you will have to have an attibute of type wdy_boolean.......this attribute can recieve value abap_true and abap_false.....now this will enable or disable the radio buttons accordingly you can always set the value of this attribute logicaaly and get results as you want.

now after adding this in the context node...you will bind this attribute to the enable property of the radio button you created in the layout.

and in the event handler you can code like this

if (condtion)
"this part will make it disable
wd_context->set_attribute( 
name = ' '            "give the name of the attribute you just made
value = abap_false
).

else
"this part will make it enable
wd_context->set_attribute( 
name = ' '            "give the name of the attribute you just made
value = abap_true
).

endif.

hope now you will be clear...alsoo remember not only in case of radio button but in case of input fields etc also you will be following the same method. i.e of binding the enable property

hope this may be helpfull to you.

thanks and regards,

sahai.s

Former Member
0 Kudos

Hello,

With the above logic, it will disable/enable the entire RadioGroup rather than the single Radiobutton element. But he needs to just disable the 2 elements not selected by the user.

Thanks,

Shikhil

gill367
Active Contributor
0 Kudos

Hello,

With the above logic, it will disable/enable the entire RadioGroup rather than the single Radiobutton element. But he needs to just disable the 2 elements not selected by the user.

Thanks,

Shikhil

but in anycase evenif you dont disbale the remaining button it wont be of anyuse because you cannot unselect it after selecting it once. and we are disbling the group only after selection of first radio button.

thanks

sarbjeet singh

Former Member
0 Kudos

Hi sahai,

can u send me the sample code so that it will be helpful for me.

Thanks & Regards,

Naveen

sahai
Contributor
0 Kudos

Method ONACTIONENABLE_DISABLE.

DATA lo_nd_radio_node2 TYPE REF TO if_wd_context_node.
  DATA lo_el_radio_node2 TYPE REF TO if_wd_context_element.  DATA lw_index            TYPE I.
  DATA lo_el_radio_node2_1 TYPE ref to if_wd_context_element. 
  * navigate from <CONTEXT> to <RADIO_NODE2> via lead selection
  lo_nd_radio_node2 = wd_context->get_child_node( name = wd_this->wdctx_radio_node2 ).* call method get lead selection index to get index 
  CALL METHOD lo_nd_radio_node2->get_lead_selection_index
    receiving
      index  = lw_index.        lo_el_radio_node2_1 = wd_context->get_element(  ).    If lw_index = 1.  * call method set attribute property and pass value as 'X' to ENABLE 
  call method lo_el_radio_node2_1->set_attribute_property
    exporting
      attribute_name = 'FIRST_NAME_2'
      property       = 4
      value          = 'X'.
* call method set attribute property and pass value as 'X' to ENABLE 
  call method lo_el_radio_node2_1->set_attribute_property
    exporting
      attribute_name = 'LAST_NAME_2'
      property       = 4
      value          = 'X'.        ELSE. 
* call method set attribute property and pass value as SPACE to DISABLE
  call method lo_el_radio_node2_1->set_attribute_property
    exporting
      attribute_name = 'FIRST_NAME_2'
      property       = 4
      value          = space.* call method set attribute property and pass value as SPACE to DISABLE
  call method lo_el_radio_node2_1->set_attribute_property
    exporting
      attribute_name = 'LAST_NAME_2'
      property       = 4
      value          = space.  
   Endif.

Endmethod.