cancel
Showing results for 
Search instead for 
Did you mean: 

How to bind 'keyToSelect' property of Radio button dynamically ?

Former Member
0 Kudos

Hi,

I my view, i have a radiobutton and its 'keyToSelect' property should be binded dynamically based on my requirement. I have corresponding node with multiple attributes.

Please point me to some sample code on how to achieve this.

Thanks & Regards,

Gaurav.

Accepted Solutions (0)

Answers (2)

Answers (2)

Former Member
0 Kudos

Answered

Former Member
0 Kudos

Hi,

I have 2 context atribute of type String with default values as DW and CN.

Bind 1st one to 1st radio button, 2nd to 2nd radio button.

In the below link I have for the selectedKey also.

Please refer this link -

Regards,

Lekha.

Former Member
0 Kudos

Lekha,

Can you please be more specific ? if possible, please help by pasting the code here. sorry that, i was unable to grasp the required code from your pointed topic.

Thanks,

Gaurav.

Former Member
0 Kudos

Hi,

For ex:

Create 3 context attributes as string

DW,CN, GROUP and give defalut values as DW for DW attribute and CN for CN attribute.These are directly under root node.

Now bind Key to Select property of the 1 radiobuttons to DW and CN respectively.

And for these 2 buttons, KEYTOSELECT is bound to GROUP.

in the WDDDOINT- 
* Set single attribute
lv_group = 'CN'.                   
      CALL METHOD wd_context->set_attribute
        EXPORTING
          value = lv_group
          name  = wd_assist->gc_group.         "`GROUP`

Implement the event onSelect for 2 radiobuttons -

DATA:
       lv_group LIKE ls_context-group.

*Move the type of display to the context attribute
  lv_group = wdevent->get_string( wd_assist->GC_key ).     "'KEY'.

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

  if wd_comp_controller->gref_element is not initial.

* Set single attribute
    CALL METHOD wd_comp_controller->gref_element->SET_ATTRIBUTE
      EXPORTING
        VALUE = lv_group
        NAME  = wd_assist->gc_group.        "`GROUP`
  endif.                                   "IF wd_comp_controller->gref_element is not initial.

Regards,

Lekha.

Former Member
0 Kudos

Dear Lekha,

Will this code be applicable to dynamically set the 'keyToSelect' property of a radiobutton, if it resides inside a table as well ?

Thanks,

Gaurav.

Former Member
0 Kudos

Hi,

Are the radio buttons are inside the table UI element.

And if the context attributes are inside the node to which the TAble is bound then you need to update the internal table as well

then bind the internal table to node.

For Ex: I have the following node bound to the Table UI element have attributes like

VBELN(Text view), ERDAT(Text View), RB1(Radiobutton),RB2(Radiobutton),GROUP(Hidden field). RB1, RB2,GROUP have string types.

To the KEYTOSELECT property of the radiobuttons, bind to the GROUP.

Bind SelectedKey to RB1 for 1st radiobutton, bind selectedkey to RB2 of 2nd radiobutton.


  DATA lo_nd_vbak TYPE REF TO if_wd_context_node.

  DATA lt_vbak TYPE wd_this->elements_vbak.
  DATA ls_vbak TYPE wd_this->element_vbak.

* navigate from <CONTEXT> to <VBAK> via lead selection
  lo_nd_vbak = wd_context->get_child_node( name = wd_this->wdctx_vbak ).

  SELECT * FROM vbak INTO CORRESPONDING FIELDS OF TABLE lt_vbak
  WHERE vbeln = lv_vbeln.

loop at lt_vbak into ls_vbak.
ls_vbak-group = 'X'.                             "KeyToSelect
ls_vbak-rb1 = 'X'.                                "By default first radiobutton is selected for all rows
modify lt_vbak from ls_vbak index sy-tabix.
endloop.

* @TODO handle non existant child
  IF lo_nd_vbak IS NOT INITIAL.
    lo_nd_vbak->bind_table( lt_vbak ).
  ENDIF.

Regards,

Lekha.