cancel
Showing results for 
Search instead for 
Did you mean: 

How to link Radio Button and the dropdown?

Former Member
0 Kudos

hi

I have created 6 radio buttons.This is my coding at wdInit() of my view:

    IPrivateOrder_Entry_view1.IRadioButton1Node radiobutton = wdContext.nodeRadioButton1();
    IPrivateOrder_Entry_view1.IRadioButton1Element elementRadio;
    String[] check = { "Buy", "Sell", };

    for (int j = 0; j < check.length; j++)
    {
      elementRadio = wdContext.nodeRadioButton1().createRadioButton1Element();
      wdContext.nodeRadioButton1().addElement(elementRadio);
      elementRadio.setBuy(check[j]);
      wdContext.nodeRadioButton1().setSelected(elementRadio.index(), false);
    }

    IPrivateOrder_Entry_view1.IRadioButton2Node radiobutton1 = wdContext.nodeRadioButton2();
    IPrivateOrder_Entry_view1.IRadioButton2Element elementRadio1;
    String[] choice = { "InFlow", "OutFlow", };

    for (int j = 0; j < choice.length; j++)
    {
      elementRadio1 = wdContext.nodeRadioButton2().createRadioButton2Element();
      wdContext.nodeRadioButton2().addElement(elementRadio1);
      elementRadio1.setInflow(choice[j]);
      wdContext.nodeRadioButton2().setSelected(elementRadio1.index(), false);
    }

    IPrivateOrder_Entry_view1.IRadioButton3Node radiobutton2 = wdContext.nodeRadioButton3();
    IPrivateOrder_Entry_view1.IRadioButton3Element elementRadio2;
    String[] select = { "Capital", "Revenue" };
    for (int j = 0; j < select.length; j++)
    {
      elementRadio2 = wdContext.nodeRadioButton3().createRadioButton3Element();
      wdContext.nodeRadioButton3().addElement(elementRadio2);
      elementRadio2.setCapital(select[j]);
      wdContext.nodeRadioButton3().setSelected(elementRadio2.index(), false);
    }

I have a drop down with export and import values .

I want that if user chooses radio button sell then,value export is selected in drop down and radio button outflow is selected or if buy is selected the value import is selected and radio button inflow is selected.This all should happen on my Action of Validation Button

Regards

Nidhideep

Message was edited by: Armin Reichert

Changed i to j to avoid formatting as italics

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

Assuming you have bound RadioButtonGroupByIndex elements to nodes RadioButton1,...

<i>I want that if user chooses radio button sell then,value export is selected in drop down and radio button outflow is selected</i>

Create an action "SellOptionsSelected" and assign it to the "onSelect" event of the radio button group.

In the action handler, write

void onSellOptionsSelected(...)
{
  /* you could also use index instead of attribute value */
  String selection = wdContext.currentRadioButton1Element().getBuy();
  if ("Sell".equals(selection))
  {
    /* set selection of drop-down node */
    wdContext.node<your-node-here>().setLeadSelection(<index-for-export>);

    /* select radio button "OutFlow" (index = 1) */
    wdContext.nodeRadioButton2().setLeadSelection(1);
  }
}

Armin

Former Member
0 Kudos

hi

I have made three RadioButtonGroupByKey and bound its element each to RadioButton1 ,RadioButton2,RadioButton3.

My context has a value node order_entry under which i have valueNodes RadioButton1(attribute buy),value node RadioButton2(Attribute inflow),RadioButton3(attribute capital).And then i have done coding i explained earlier in my postings.I have a dropdownbykey with 4 values {Export,import,receipt,payment).Armin your code is not working and Sridhar i am clear with ur idea,especially regarding wht is DDVAL?

Please help me

Regards

Nidhideep

Former Member
0 Kudos

sridhar i am not clear with ur idea?

Former Member
0 Kudos

Your are confusing me. The code you posted creates context data suitable to bind RadioButtonGroup<b>ByIndex</b> elements. But now you tell that you use RadioButtonGroup<b>ByKey</b>.

Armin

sridhar_k2
Active Contributor
0 Kudos

Hi,

As you select Sell,Outflow...from RadioButtons Group, Corresponding Export, import has to be selected from Drop Down. Is it right?

Sell - Export

Buy- Import

Outflow - Recipt

Inflow - Payment

Please Correct me, if i am not correct.

Regards,

Sridhar

Message was edited by: Sridhar kanchanapalli

Former Member
0 Kudos

hi

Sridhar i am providing you with matrix of my logic

Buy/sell inflow/outflow Cash/Revenue

Exports sell Inflow Revenue

Import Buy outflow Revenue/cash

Payment Buy outflow Revenue/cash

Receipt sell Inflow Revenue

It means if click on my validate button:

First case:

Then whtever the user selected but if he has selected Exports (dropdown)then radio button sell is selected (which is in RadioGroup1),inflow is selected(from RadioGroup2,Revenue is selected (from RadioGroup3).

Regards

Nidhideep

sridhar_k2
Active Contributor
0 Kudos

Hi,

<b>First Case</b>

If the user Selects Exports from DropDown, then RadioButton1 value has to be selected.

For this,

Create a SimpleType with Enum val as Export(Value) – Export(txt) and assigned this to context value(dropDownVal) which is bind to dropdown.

In the "onActiondropDownSelected" - Action which is bind to DropDown - onSelect Property.


String selectedVal = context.getDropDownVal();
if(selectedVal != null || selectedVal.equalsIgnoreCase("")){
if(selectedVal.equalsIgnoreCase("Exports")){
wdContext.nodeRadioButton1().currentRadioButton1Element().setBuy(selectedVal);		
}
}

In the same way you do for other drop down values. by Adding else conditions.

Regards,

Sridhar

Regards,

Sridhar

Former Member
0 Kudos

hi

Sridhar

I have made a simple type Export in my Enum with Val Ex,

And then bind it to dropdown and onselect event i have bind Action selectdropdown:

The coding that i ahve done in action is:

String selectedVal = wdContext.currentDropDownElement().getType();

if(selectedVal != null || selectedVal.equalsIgnoreCase("")){

if(selectedVal.equalsIgnoreCase("EXPORT")){

wdContext.nodeRadioButton1().currentRadioButton1Element().setBuy("Buy");

}

}

But result is not coming.

Regards

Nidhideep

sridhar_k2
Active Contributor
0 Kudos

Hi,

Can you please check, what this selectedVal is giving output by using MessageManager.


String selectedVal = wdContext.currentDropDownElement().getType();
//testing purpose
manager.reportSuccess("selectedVal "+selectedVal);
if(selectedVal != null || selectedVal.equalsIgnoreCase("")){
if(selectedVal.equalsIgnoreCase("EXPORT")){
wdContext.nodeRadioButton1().currentRadioButton1Element().setBuy("Buy");
//testing purpose
manager.reportSuccess("Came Here");
}
}

I doubt on your "setBuy("Buy");" Make it as "setBuy("buy");.

Check with your RadioButton1.buy - simple type. You might have declared it as 'buy'.

Regards,

Sridhar

Former Member
0 Kudos

Still confused about your posts.

What kind of RadioButtonGroup are you using, *ByIndex or *ByKey?

If you are using *ByIndex and you want to select the radio button at index <i>idx </i>(index counting starts with 0), then you have to use code like

String selectedVal = wdContext.currentDropDownElement().getType();
if ("EXPORT".equals(selectedVal))
{
  wdContext.nodeRadioButton1().setLeadSelection(idx);
}

Armin

Former Member
0 Kudos

hi

Armin and Sridhar i have solved my problem.Thanx for so much support.But i want some more enhancement.I am showing you my code:

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

{

//@@begin onActiondropdownselected(ServerEvent)

String selectedVal = wdContext.currentDropDownElement().getType();

if(selectedVal != null || selectedVal.equalsIgnoreCase("")){

if(selectedVal.equalsIgnoreCase("EXPORT")){

****/for my selection of my buy radio button **/

wdContext.nodeRadioButton1().setLeadSelection(1);

****/for my selection of my inflow radio button **/

wdContext.nodeRadioButton2().setLeadSelection(0);

****/for my selection of my Cash radio button **/

wdContext.nodeRadioButton3().setLeadSelection(1);

}

I want that when Export is selected sell Radio Button is selected and Buy Radio Button is grayed out or not visible.Buy and sell belongs to same RadioButton group by index(Armin i am sorry to confuse you).Ans same for other cases.

Please help me

Regards

Nidhideep

Former Member
0 Kudos

Hi

in your code your condition not matches the "" check.

try this

if(selectedVal != null && !selectedVal.equalsIgnoreCase("")){

if(selectedVal.equalsIgnoreCase("EXPORT")){

****/for my selection of my buy radio button **/

wdContext.nodeRadioButton1().setLeadSelection(1);

****/for my selection of my inflow radio button **/

wdContext.nodeRadioButton2().setLeadSelection(0);

****/for my selection of my Cash radio button **/

wdContext.nodeRadioButton3().setLeadSelection(1);

}

Kind Regards

Mukesh

Former Member
0 Kudos

hi

Mukesh you are not getting my point.

I want that when user select export from dropdown,then sell Radio button will be selected ,and buy radio button should be grayed out or not Visible.These radio button belongs to same Radio button group by index.

Regards

Nidhideep

sridhar_k2
Active Contributor
0 Kudos

Hi Nidhideep,

Check your condition like this.

if(selectedVal != null || !(selectedVal.equalsIgnoreCase(""))){

}

If you do not want to show(invisible) the any control, then create a context variable(visibleVar) with type as

com.sap.ide.webdynpro.uielementdefinitions.Visibility and assign this variable to control visible property.

context.setVisibleVar(WDVisibility.BLANK);

//To make visible context.setVisible(WDVisibility.VISIBLE);

Regards,

Sridhar

Former Member
0 Kudos

Hi

create a boolean attribute and bind it with the enabled property of Radio button . You can set the enabled property at run time.

wdContext.currentContextElement().set<Param>(false);

Kind Regards

Mukesh

sridhar_k2
Active Contributor
0 Kudos

Hi,

I Don't think, you can make invisible for a particular radio button from Group By Index. Mukesh's answer will inactivate both the radio buttons.

Correct me, if there a way to do that one.

Regards,

Sridhar

Message was edited by: Sridhar kanchanapalli

Answers (2)

Answers (2)

Former Member
0 Kudos

Hi plz check the following link

i hope it will be helpfull to u.

Thanks

Kindly do reward Points.

sridhar_k2
Active Contributor
0 Kudos

Hi Nidhideep,

If I Understood you requirement correctly, you want to show corresponding radio button value in the Drop Down and vice versa. If Sell is selected in RadioButton Export should appear on DropDown.

Follow the below steps.

Create simple type with values Sell(val) - Export(Txt) , Buy-Import and assign this to DropDownByKey.

Create two Actions RadioButtonSelected , DropDownSelected.

Assing RadioButtonSelected Action to RadioButtonGroupByKey - OnSelect Property.

//on the Action Method paste this code

IWDNodeInfo nodeInfo = wdContext.getNodeInfo();

IWDAttributeInfo attrInfo = nodeInfo.getAttribute(context.DDVAL);

//DDVal is the simple type assigned to DropDown

IModifiableSimpleValueSet valueSet = attrInfo.getModifiableSimpleType().getSVServices().getModifiableSimpleValueSet();

String first = null;

if(valueSet != null){

first = (String)valueSet.getText(context.getFirstradion().trim());

//context.getFirstradion - radion button assigned context val

}

context.setDdval(first);

//assigns first (Import / Export) to Drop Down.

Assing DropDownSelected Selected Action to Drop Down On Select.

String selectedVal = context.getDdval();

//Assing Selected DropDown val to Radio Group by Key

context.setFirstradion(selectedVal);

I have done for only Buy and Sell.

Reply me back, if you want any clarifications.

Regards,

Sridhar