cancel
Showing results for 
Search instead for 
Did you mean: 

select one radio button at a time

Former Member
0 Kudos

Hi all,

my webdynpro table contains 3 rows. each row contains one radio button. at a time i should select only one radio button and bydefault the first one should be select.

Thanks,

Sagarika

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

Hi,

when the view will load, bydefault radio button of first row of webdynrpo table should check. in this part i am facing problem.

in my onaction-method i wrote the down code for 'deselect radio button if i will select other one'.my node is 'paticipants'.

" Uncheck other Radio button if selected

DATA: lo_nd_participants TYPE REF TO if_wd_context_node,

lo_changed_elem TYPE REF TO if_wd_context_element,

lo_elem TYPE REF TO if_wd_context_element,

lt_elem_set TYPE wdr_context_element_set,

ls_chgd_participant TYPE LINE OF wd_this->elements_participants,

ls_participant TYPE LINE OF wd_this->elements_participants.

FIELD-SYMBOLS:

<fs_participant> TYPE LINE OF wd_this->elements_participants.

" Get the changed context row

CALL METHOD wdevent->get_context_element

EXPORTING

name = 'CONTEXT_ELEMENT'

RECEIVING

value = lo_changed_elem.

" Get static attributes

CALL METHOD lo_changed_elem->get_static_attributes

IMPORTING

static_attributes = ls_chgd_participant.

" Navigate from <CONTEXT> to <PARTICIPANTS> via lead selection

lo_nd_participants = wd_context->get_child_node( name = wd_this->wdctx_participants ).

IF lo_nd_participants IS INITIAL.

RETURN.

ENDIF.

" Get all the selected elements from the context

lt_elem_set = lo_nd_participants->get_elements( ).

" Process the elements

LOOP AT lt_elem_set INTO lo_elem.

CALL METHOD lo_elem->get_static_attributes

IMPORTING

static_attributes = ls_participant.

IF ls_participant-prim_userid NE ls_chgd_participant-prim_userid.

ls_participant-admin_ind = abap_false.

lo_elem->set_static_attributes( ls_participant ).

ENDIF.

ENDLOOP.

Former Member
0 Kudos

Hi Sagarika,

Basically in the INIT method itself you need to set the property for initial radio button and clear the other two radio buttons . And when you select any radio button code in the action handler should be written such that other two are cleared and only one is selected every time and that action handler should be able to clear other radio buttons selection.

Check if this idea helps.

Former Member
0 Kudos

Hi,

Try using this


   DATA LO_ND_participant TYPE REF TO IF_WD_CONTEXT_NODE.
    DATA LO_EL_participant TYPE REF TO IF_WD_CONTEXT_ELEMENT.
    DATA LS_participant TYPE WD_THIS->ELEMENT_participant.
    DATA LT_participant TYPE WD_THIS->ELEMENTS_participant.
    data ind type index.
*   navigate from <CONTEXT> to <participant> via lead selection
    LO_ND_participant = WD_CONTEXT->GET_CHILD_NODE( NAME = WD_THIS->WDCTX_participant ).

*   @TODO handle not set lead selection
    IF LO_ND_participant IS INITIAL.
    ENDIF.

*   get element via lead selection
    LO_EL_participant = LO_ND_participant->GET_ELEMENT(  ).

*   @TODO handle not set lead selection
    IF LO_EL_participant IS INITIAL.
    ENDIF.
    data : ele_set type ref to if_wd_context_element.

CALL METHOD WDEVENT->GET_CONTEXT_ELEMENT
  EXPORTING
    NAME   = 'CONTEXT_ELEMENT'
  RECEIVING
    VALUE  = ele_set .

data : ind type index.
CALL METHOD ELE_SET->GET_INDEX
  RECEIVING
    MY_INDEX = ind
    .




    CALL METHOD LO_ND_participant->GET_STATIC_ATTRIBUTES_TABLE
*      EXPORTING
*        FROM   = 1
*        TO     = 2147483647
      IMPORTING
        TABLE  = lt_participant
        .

    loop at lt_participant into ls_participant.

    if sy-tabix = ind.
      ls_participant-admin_id = ''.        " Radio button selected
    else.
      ls_participant-admin_id = 'X'.      "Radio button not selected
      endif.
    modify lt_participant from ls_participant TRANSPORTING admin_id.
    endloop.
    lo_nd_participant->bind_table( lt_participant ).

Answers (3)

Answers (3)

Former Member
0 Kudos

Hi harshith,

Thanks a lot. It worked perfectly for me.

Regards,

Sagarika

former_member184578
Active Contributor
0 Kudos

Hi Sagarika,

I hope you already changed the column of table UI to radio button. Now create an action for onselect of radio button,

In the method of onSelect of Radio button,

You read the table using, get_static_attributes_table method of node.

Now loop your internal table, if two radio buttons are selected, display error message.

like

loop at lt_tab into ls_tab.

if ls_tab-radio = 'X'.

count = count + 1.

endif.

endloop.

if count > 1.

display error message using report_error_message of message manager.

endif.

Hope this helps u.,

revert for further clarifications.,

Thanks & Regards,

Kiran.

Former Member
0 Kudos

Hi Sagarika,

Can you please mention the problem you are facing or whether you are getting any error, so that

any one could help you.