cancel
Showing results for 
Search instead for 
Did you mean: 

Radio button in table

Former Member
0 Kudos

Hi Experts

My Problem is i need 2 RadioButtons in a Table.so i have inserted 2 RadioButtons (Accept & Reject)in

cellEditor and i have binded those values to the boolean value which is coming from the BackEnd

.but my problem is i can select both the radiobuttons and on selecting it is showing an error

is Not A Valid value.but i need only one radio button to be selected for a row.How can i get this?

Regards,

Asif

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

hi ...

Your inserting two radio buttons in a row of a table ,one radio button for one column...

Since you cannot use RadioButtonGroupByIndex in a table column as a table Cell Editor ....

You can follow this

take two attributes in the context as b1 and b2 of type boolean.

Bind this attributes to the radiobutton enable property

for example

b1---for enable property of Accept radio button

b2 -- for enable property of Reject Radio button.

Take two actions for two Radiobuttons

In the onSelect action of the Accept radio button you write as below

wdcontext.currentcontextelement.setb1(false);

In the onSelect action of the Reject radio button you write as below

wdcontext.currentcontextelement.setb2(false);

in wdinit() write as follows

wdcontext.currentcontextelement.setb1(true);

wdcontext.currentcontextelement.setb2(true);

hope it helps

If any queries reply back

Regards

Madhavi

Former Member
0 Kudos

Hi madhvi thanks for the reply

i have tried already the thing is that if i do like that the other rows values also get disabled

say if i select accept corresponding reject has to be disabled isn't it but all other reject buttons of remaining rows also get disabled at the same time

Former Member
0 Kudos

hi ....

Take the boolean variables b1 and b2 in the node which you are

binding it for the table instead of declaring them as context attributes..

you can get you functionality.if any queries reply back

Regards

Madhavi

Former Member
0 Kudos

Thanks for reply

but i cant declare the value attributes inside a model node for the i need to create value node inside the modelNode then i have to declare the value attributes so what shall i do know.

Thanks&Reagrds

Asif

Former Member
0 Kudos

Add a helper value node (cardinality=1:1, selection=1:1) and put any additional attributes there.

Armin

Former Member
0 Kudos

Thanks for reply

I have created a value node with a cardinality1:1 and selection as1:1 with the attributes

1.accept

2.reject

in init() method im writing this code

wdContext.nodeElement().currentElementElement().setAccept(true);

wdContext.nodeElement().currentElementElement().setReject(true);

on deploying the application it is giving null pointer exception.what to do

Former Member
0 Kudos

Hi every one

i got the solution with small problem

we have to create our own attributes of type string

say 1.accept-string

2.reject-string

for accept give keyToSelect value as "a" and for reject as"r"

bind the selectedKey to corresponding attribute

now onSelect write this code

public void onActionaccept(com.sap.tc.webdynpro.progmodel.api.IWDCustomEvent wdEvent )

{

//@@begin onActionaccept(ServerEvent)

if(wdContext.currentContextElement().getAccept()=="a")

{

wdContext.currentContextElement().setReject(null);

wdContext.nodeTable().currentTableElement().setAccept(true);

}

similar thing for reject also

but the thing is that

now im able to select only one button at a time but if i select accept corresponding all accept buttons of rows get selected as im getting data from backend ....please some one guide me what to do

Former Member
0 Kudos

I forgot to say that the value node must be non-singleton (singleton=false) such that it exists for every parent node element (table row).

Say you have the following context structure:


Rows (node, c=0:n, s=0:n)
-- Selection (node, c=1:1, s=1:1, singleton=false)
---- value (string)

Add two table columns "AcceptColumn" and "RejectColumn", and add two RadioButtons "AcceptButton", "RejectButton" as cell editors. Bind the "selectedKey" property of both radio buttons to attribute "Rows/Selection/@value". Further assign an action (at least a dummy action) to both buttons.

Now, to initialize the values for the table rows, write code like


for (int i = 0, n = wdContext.nodeRows().size(); i < n; i++)
{
  IRowsElement row = wdContext.nodeRows().getRowsElementAt(i);
  /* this line defines which radio button should be selected in the row at index i: */
  row.currentSelectionElement().setValue("accept"); /* or "reject" */
}

To check the value of the radio buttons in row at index i:


IRowsElement row = wdContext.nodeRows().getRowsElementAt(i);
String value = row.currentSelectionElement().getValue();
if ("accept".equals(value))
{
}
else if ("reject".equals(value))
{
}
else
{
  /* null or illegal value */
}

Armin

Former Member
0 Kudos

Thanks Armin .your suggestion was good and it is working fine .thanks alot

Regards

Asif

Answers (2)

Answers (2)

Former Member
0 Kudos

Hi,

Use radiobuttongroupbykey.Create simpletype and create Accept and Reject in Enumeration by giving value fields 1 and 2.

Now in cintext create one value node and in it create value attribute.

To this attr assign simple type.

Now in layout ,to this radiobutton ,assign this value attribute to selected key property.

Go to the implementation and inside init method wrie down

wdContext.currentCtx_vn_radiobuttonElement().setCtx_va_rdb("1");

so that it will set selected the fisrt radio button.

Now before executing RFC write down the code:

If you are getting first radio button selected then in RFC give that perticular value as "X" and at the same time give other value as blank "".This will not let both the buttons selected.

if (wdContext.currentCtx_vn_radiobuttonElement().getCtx_va_rdb().equals("1"))

{

wdContext.current<backendnode>().set<modelatrr1>("X");

wdContext.current<backendnode>().set<modelatrr2>("");

}

if (wdContext.currentCtx_vn_radiobuttonElement().getCtx_va_rdb().equals("2"))

{

wdContext.<backendnode>().<modelatrr2>("X");

wdContext.current<backendnode>().set<modelatrr1>("");

}

and then execute RFC.

Hope it will help.

Regards

Prajakta

Former Member
0 Kudos

Hi,

Use RadioButtonGroupByIndex.

thanks & regards,

Manoj

Former Member
0 Kudos

Hi Manoj thanks for reply

but i can't use RadioButtonByGroup or Index because Table Cell Editor will not allow you to do this

you have to insert individual RadioButtons