cancel
Showing results for 
Search instead for 
Did you mean: 

Radio Button in Table

Former Member
0 Kudos

Hi All,

I have small requirement in Web Dynpro. I have to display radio button as a column in table and user can only select one radio button (i.e. User can enter multiple phone numbers in a table but he can only select one number as default). How to do this functionality? If anybody knows, please advice me.

If anybody has sample code that would be great help.

Thanks & Regards,

IA Kumar.

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

Hi Anil,

You need to use KEY_TO_SELECT and SELECTED_KEY properties of the radio button .

Documentation of above attributes ( help.sap.com )

keyToSelect-Value of the key used to select this RadioButton.

selectedKey-Path to the context attribute that stores the selected key.

For a radio button to work in a table, there should be a key which differentiates the each row from other.

<b>Key_to_select</b> shoulb be bound to above key which exists in the structure used to display the table.

Have an attribute outside of the above node ( having cardinality of 0..n or 1..n ). Data element of this attribute should be same as the above key element's attribute.

Bind the SELECTED_KEY property to this attribute. So, if any radio button is selected value of the row's key will be copied to the attribute which is bound to SELECTED_KEY property.

EG:

Table is having 5 rows, lets take each row's primary key is row number which should exist in the structure .

Now user selected second row, then context attribute which is bound to SELECTED_KEY will be populated with value 2( which is key of the second row ).

while updating the data of the table, get the value of the SELECTE_KEY attribute and depending on that set the flag for for that row or do any logic that needs to be done.

While displaying the data, get the key of the row for which radio button needs to be checked (selected ), populate that key in SELECTED_KEY's attribute. Automatically, webdynpro wll select the corresponding row's radio button.

Hope this will help you.

Thanks,

Prashanth

Former Member
0 Kudos

Thanks Prashanth for you help.

Just to Check with you. I tried as you specified but context attribute which is bound to SELECTED_KEY is getting populated as 'X' instead of row. Can you please suggest me why it is population X instead of row number.

Thanks & Regards,

IA Kumar.

Answers (2)

Answers (2)

Former Member
0 Kudos

Hi Anil,

To which attribute KEY_TO_SELECT property is bound?. Here, it seems it is bound to an attribute which is of type XFIELD. This key should be bound to an attribute which acts like a primary key in the table then only it rerurns the key of the row which is selected to SELECTED_KEY attribute. Depending on the key Selected you have to set the true flag to corresponding row.

thanks,

Prashanth

Former Member
0 Kudos

Hi Prashanth,

Your Right. It's Working fine Now. Thank you so much prashanth.

Regards,

Anil

Former Member
0 Kudos

Hi Anil,

It is not possible to have multiple radio buttons in a single cell of a column. You should use a drop down instead.

Regards,

Neha