cancel
Showing results for 
Search instead for 
Did you mean: 

how to create 5 Radio Buttons selecting one at a time

Former Member
0 Kudos

Hi Folks,

I am trying to create 5 radio buttons, out of which at a time only once should be selected.

I am not able to use UI Element Radiobutton group by index/ Key , since they are not giving option of creating 5 radiobuttons.(

Correct me if they do give).

Then i decided to go for UI Element Radiobutton, but the issue in this case is, that all the radiobuttons( all 5) are by default

selected.

So how to unselect all the radiobuttons. Is there any other way to implement this requirement.

Regards

PG

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

Hi PG,

There are more than two ways of going about it, however the mentioned two ways are the commonly used ones.

First one is using UI Element: RadioButtonGroupByIndex

Here, you need to create a node with cardinality 0:N and bind the text property of the UI element to the attribute which is of character type to hold the descriptions of each radio button. Here the selectoin will be based on the lead selection.

Second way is using UI Element: RadioButtonGroupByKey

Here, the cardinality to be used is 0:1 for the node and the selected key property is binded to an attribute with character value.

Use, the following dictionary structure(WDY_KEY_VALUE) and table type (WDY_KEY_VALUE_TABLE) to create the attribute infomation before you use, set_attribute_value_set method of if_wd_context_node_info to populate the values.

Suppose, your node name is Key and attribute name is atri_key


DATA: lr_nd_key_info type ref to if_wd_context_node_info,
            wa_key type wdy_key_value,
            t_key type wdy_key_value_table.
*Populate values in the table.
wa_key-key = (Give Name of Key).
wa_key-value = (Give description of key)
append wa_key to t_key.

lr_nd_key_info = wd_context->get_node_info( ).
lr_nd_key_info = lr_nd_key_info->get_child_node(  'KEY'  ).
lr_nd_key_info->set_attribute_value_set( name = 'ATRI_KEY'  value set = t_key ).

Regards,

Rajesh

Answers (4)

Answers (4)

Former Member
0 Kudos

Dear PG,

You can toggle the radio button when you bind the UI elements to the same context attribute.

This has worked out for me.

Regards,

-Syed.

Chaitanya_Priya
Product and Topic Expert
Product and Topic Expert
0 Kudos

Hi ,

1.Insert UI element RADIOBUTTONGROUPBYINDEX under Group

2.Create data binding from Layout tab UI Elements to context node RADIOGROUP(create a node with tht name)

3. for this UI element

Create an Action In properties Events under OnSelect click on New Button and Enter name of the Action u201CSELECTITEM

4. Switch to tab Methods of view and double-click method WDDOINIT. Enter the given coding

5.On initialization of view MAINVIEW, the content is loaded into an internal table and assigned to the data structure of context node RADIOGROUP.

method WDDOINIT .
  Data : v_Element type ref to If_Wd_Context_Element,
         Items_node type ref to If_Wd_Context_node,
         v_Index type i,
         v_Text type string,
         itemList type STANDARD TABLE OF IF_MAINVIEW=>ELEMENT_radiogroup,
         w_list LIKE LINE OF itemList.* Appending elements to "itemList"
w_list-ebeln = 'Blue'.
     append w_list to itemList.
w_list-ebeln = 'Yellow'.
     append w_list to itemList.
w_list-ebeln = 'Red'.
     append w_list to itemList.
w_list-ebeln = 'Magenta'.
     append w_list to itemList.
w_list-ebeln = 'White'.
     append w_list to itemList.
w_list-ebeln = 'Black'.
     append w_list to itemList.Items_node = wd_Context->get_Child_Node( Name = `RADIOGROUP` ).
Items_node->bind_table( itemList ).
Items_node->SET_LEAD_SELECTION_INDEX( 3 ).
v_Index = Items_node->GET_LEAD_SELECTION_INDEX( ).
clear w_list.
read table itemList into w_list index v_Index.
v_Text = w_list-ebeln.
wd_Context->set_Attribute( exporting value = v_Text  NAME = 'VIEWTEXT'  ).

endmethod.

Priya

0 Kudos

Hi,

You can create a UI element which typ is 'RadioButtonGroupByKey' and bind the selectedkey from context node attribute, then set value to the attribute.

for example:

DATA lo_nd_radio_button TYPE REF TO if_wd_context_node.

DATA lo_nd_radio_button_info TYPE REF TO if_wd_context_node_info.

DATA lt_r1 TYPE TABLE OF wdr_context_attr_value.

DATA ls_r1 TYPE wdr_context_attr_value.

lo_nd_radio_button = wd_context->get_child_node( name = wd_this->wdctx_radio_button ).

lo_nd_radio_button_info = lo_nd_radio_button->get_node_info( ).

ls_r1-value = 'A'.

ls_r1-text = 'test1'.

APPEND ls_r1 TO lt_r1.

ls_r1-value = 'B'.

ls_r1-text = 'test2'.

APPEND ls_r1 TO lt_r1.

ls_r1-value = 'C'.

ls_r1-text = 'test3'.

APPEND ls_r1 TO lt_r1.

ls_r1-value = 'D'.

ls_r1-text = 'test4'.

APPEND ls_r1 TO lt_r1.

lo_nd_radio_button_info->set_attribute_value_set(

name = 'R1'

value_set = lt_r1 ).

then you will find there are four radio buttons in the UI, and thery are in one group.

Edited by: Julia Zhu on Dec 15, 2009 1:48 PM

Former Member
0 Kudos

Well a radio button group should solve your problem.

How did you give the radio button group the available options?