cancel
Showing results for 
Search instead for 
Did you mean: 

Radio Button in a table

Former Member
0 Kudos

Hi ,

My requirement is to have a radio button in a table .

scenerio : i have 3 coloumns in a table as shown below

From Date To Date Select

Select coloumn is a radio button . i made that coloumn to a radio button in table not in SALV .

Now , data will be fetched from the DB for first two coloumns and where the difference of FROMDATE AND TODATE will be greater or equal to 5 only those rows should have a active radio button which can be clicked .

Other rows should have disabled radio button.

Moreover , User can select only one radio button at a time .

if it can be possible with SALV , suggest me that option as well.

Thanks.

Accepted Solutions (1)

Accepted Solutions (1)

saravanan_narayanan
Active Contributor
0 Kudos

Hello,

find the steps to achieve your requirement with normal table UI element. I'm not sure whether the same will work for alv. I expect it to work

1. Create one boolean attribute in the Table Context node to indicate whether the radio button should be enabled or not (Attribute name : say RB_ENABLED). Populate the value of this attribute based on your From_Date DIF TO_DATE >= 5.

2. Create a string attribute in the table context node to indicate the value for the radio button (Attribute Name: say RB_VALUE)

Populate the Value of this attribute like for first record say FIRST and second record say SECOND. Or if you have unique Id for each row then you populate the same here.

This attribute is required to identiy which radio button is selected by the user

3. Create a context node (say RB_SELECTED) of cardinality 1..1 and an attribute of type string (say RB_SELECTED)

4. In the table ui element, create a Radio button column and bind the following

enabled property to RB_ENABLED attribute

KeyToSElect to RB_VALUE attribute

SElectedKEy to RB_SELECTED.

So at runtime whenever the user selects a radio button, the correpsonding value will be set in the RB_SELECTED attribute. example if the user selects the radio button in the first row, the value 'FIRST' will be populated in the RB_SELECTED attribute.

BR, Saravanan

Former Member
0 Kudos

Hi Saravanan,

Thanks for the valueable inputs .

Now the radio button where difference is less than 5 are disabled but the all the radio button are coming already checked .

i did all the steps right but now i have two rows where difference is >=5 but the radio button is both the rows are already checked .

Radio buttons should be blank and should be checked by the user.

Thanks.

Nikhil

saravanan_narayanan
Active Contributor
0 Kudos

Hello Nikhil,

Did you create the new context node of cardinality 1..1 and an attribute RB_SELECTED like I mentioned in step 3. And also did you bind the SelectedKey property of the Radiobutton to RB_SELECTED.

And also did you populate the unique value for RB_VALUE attribute. If you have done all this and it should work properly as you expected. Check it again.

BR, Saravanan

Former Member
0 Kudos

Hi Saravanan ,

I did all the steps i made a node of cardinality 1:1 and binded to selectedkey .

My sample code :


LOOP AT IT_PA2001 INTO WA_PA2001.

LS_NODE_PRIVILEGELEAVE-FROM_DATE = WA_PA2001-BEGDA.
LS_NODE_PRIVILEGELEAVE-END_DATE   = WA_PA2001-ENDDA.
******condition **********
IF WA_PA2001-ABRTG >= '5.00'.
LS_NODE_PRIVILEGELEAVE-RB_ENABLED   = 'X'.
ENDIF.

APPEND LS TO LT.
ENDLOOP.

Now , here what i need to fill for RB_VALUE .

I have 4 rows in table right now of which two are disabled and two are enabled .

User can select any of the two active radio button .

Thanks

Nikhil.

saravanan_narayanan
Active Contributor
0 Kudos

Hello Nikhil,

in the RB_VALUE attribute, you need to populate a unique value. Try setting this value to sy-tabix and check.


LOOP AT IT_PA2001 INTO WA_PA2001.

LS_NODE_PRIVILEGELEAVE-RB_VALUE = sy-tabix.
LS_NODE_PRIVILEGELEAVE-FROM_DATE = WA_PA2001-BEGDA.
LS_NODE_PRIVILEGELEAVE-END_DATE   = WA_PA2001-ENDDA.
******condition **********
IF WA_PA2001-ABRTG >= '5.00'.
LS_NODE_PRIVILEGELEAVE-RB_ENABLED   = 'X'.
ENDIF.
 

APPEND LS_NODE_PRIVILEGELEAVE TO LT.
ENDLOOP.



BR, Saravanan

Former Member
0 Kudos

Hi Saravanan ,

it worked .

Thanks

Nikhil.

Answers (0)