cancel
Showing results for 
Search instead for 
Did you mean: 

Table with Radio buttons, not reflecting when I change the selection

sreemsft
Contributor
0 Kudos

Hi,

I am working on a requirement in ABAP dynpro, where I need to display a table with 3 columns, in which first column is a text and the other two columns are radio buttons.

Initially I am populating the internal table, only one radio button is checked, which is fine. But during runtime when I try to change the radio button selection, it is not reflecting in the table context. So when I go to next page and come back, in my table both radio buttons of a row is checked. Where the result should look like one radio button in a row only.

I tried with events on radio button, but it still did not work.

Could anyone give me an idea about how to work with it?

Thanks in Advance,

Sreekanth

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

Hi Shreekanth,

Try this. Create an event method for the radio button. Now when user selects radio button one you clear the attribute of radio button 2 in the event and bind the element again.

" Event for radiobutton1.
Data: l_elem type ref to if_wd_context_element.

l_elem = wdevent->get_context_element( 'CONTEXT_ELEMENT' ).
l_elem->get_static_attributes( importing static_attributes = ls_stru ).

clear ls_stru-radiobutton2. " radiobutton2 is your attribute bound to 2nd radiobutton column
l_elem->set_static_attributes( exporting static_attributes = ls_stru ).

Similarly create event for Radiobutton 2 or You can also use the same event with a little more neat coding.

Regards,

Radhika.

sreemsft
Contributor
0 Kudos

Hi Radhika,

Thanks for the reply.

I have one context node as table with three columns, First Column is Name, Second Column Accept (Radio Button), Third Column Reject (Radio Button). I have binded the same to my view table, and while binding I chose the radio buttons for the required columns.

Radio button has two properties, keyToselect and selectedKey, how to bind my context to these attributes? Somewhere I am doing wrong here. Could you let me know how to bind this?

Thanks,

Sreekanth

Former Member
0 Kudos

Hi,

What is the type ofr your attributes 'ACCEPT' and 'REJECT'?. It should be Char 1/Boolean, then set your keytoselect property to 'X' and bind the selectedKey attribute with your attributes.

Now when you select a radio button you attribute will have value 'X'.

So what you can do is as per my previous rep;y when you click radio button 'accept', clear the 'Reject' attribute.

Refer the code i have supplied in my previous reply.

Hope this helps!

Radhika.

sreemsft
Contributor
0 Kudos

Radhika,

No both of them were strings. I fixed the problem.

Actually i got how to do this. I took help of a new context attribute. and we have to give different unique value to keytoselect. depending on that i could do it.


  DATA : ITEMS_NODE TYPE REF TO IF_WD_CONTEXT_NODE,
         ITEMLIST TYPE STANDARD TABLE OF IF_MAIN=>ELEMENT_RADIO,
         W_LIST LIKE LINE OF ITEMLIST.

  ITEMS_NODE = WD_CONTEXT->GET_CHILD_NODE( NAME = 'RADIO' ).
  ITEMS_NODE->GET_STATIC_ATTRIBUTES_TABLE( IMPORTING TABLE = ITEMLIST ).
  LOOP AT ITEMLIST INTO W_LIST.
    CLEAR: W_LIST-ACCEPT,
           W_LIST-DENY.
    IF     W_LIST-SELECTEDKEY = 'a'.
      W_LIST-ACCEPT = 'X'.
    ELSEIF W_LIST-SELECTEDKEY = 'b'.
      W_LIST-DENY  = 'X'.
    ENDIF.
    MODIFY ITEMLIST FROM W_LIST INDEX SY-TABIX.
  ENDLOOP.

  ITEMS_NODE->BIND_TABLE( ITEMLIST ).

  WD_THIS->FIRE_NEXT_PLG(
  ).

Thanks,

Sreekanth

Answers (1)

Answers (1)

Former Member
0 Kudos

Hi,

While binding the internal table to node, you need to modify the internal table based on your conditions whne you get back to previous view.

Regards,

Lekha.