cancel
Showing results for 
Search instead for 
Did you mean: 

radio buttton group by index - default button

richard_pietsch
Active Contributor
0 Kudos

Hi experts,

can anyone tell me how I can define which button within a radiobuttongroup is selected by default in webdynpro?

I have a group of 5 buttons, the first one always is selected by default. But I would like to have the 3rd button as the default button

How can I achieve this?

Thanks, Richard

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

Hi Richard,

in order to change the default selected radio button, you need to set the lead selection to required node

write the below code after BIND_TABLE method where you are populating the required radio button text.

lo_<node>->bind_table( new_items = lt_<table> set_initial_elements = abap_true ).


lo_<node>->move_to( index = 3 ).

Points plz if helpful.

Regards

Subhash

richard_pietsch
Active Contributor
0 Kudos

That's it, thanks!

Answers (1)

Answers (1)

former_member184578
Active Contributor
0 Kudos

Hi,

By default the first radio button will be selected. In WDDOINIT method after populating the radio button texts and binding, Use set_lead_selection_index method to set the default selection.

Try the below code:

DATA lo_nd_radio TYPE REF TO if_wd_context_node.

     DATA lt_radio TYPE wd_this->elements_radio.

     DATA ls_radio TYPE wd_this->element_radio.

*   navigate from <CONTEXT> to <RADIO> via lead selection

     lo_nd_radio = wd_context->get_child_node( name = wd_this->wdctx_radio ).

* Fill Radio Button Texts

      ls_radio-value = 'Value1'.

      APPEND ls_radio TO lt_radio.

      ls_radio-value = 'Value2'.

      APPEND ls_radio TO lt_radio.

      ls_radio-value = 'Value3'.

      APPEND ls_radio TO lt_radio.

     lo_nd_radio->bind_table( new_items = lt_radio set_initial_elements = abap_true ).

     lo_nd_radio->set_lead_selection_index( 2 ). " Set default selected radio button

" Here I set 2nd radio button by default, you can pass the index which you want the default selecton


Hope this helps u.,

Regards,

Kiran