cancel
Showing results for 
Search instead for 
Did you mean: 

Dynamic DropDown Boxes

Former Member
0 Kudos

Dear All,

How can I create dynamic dropdown boxes?

When I select a tab, It will generate dropdown boxes dynamically.When I select one option in that dropdown box, once again it has to generate one more dropdown box.

Values for these dropdown boxes are coming from RFCs

Thanks

Rajani

Accepted Solutions (0)

Answers (4)

Answers (4)

Former Member
0 Kudos

Try this code:-

Create a static node in the componenet controller and map with the views and set the cardinality to 1..n.(say static node is-->calculation_col)

theDropDownCalc = (IWDDropDownByKey) view.createElement(IWDDropDownByKey.class, null);

secondAttInfo.addAttribute("write the any dynamic attribute name<say XXX>","<the datatype say string/boolean/integet>");

theDropDownCalc.bindSelectedKey("calculation_col.<the name of the static node created above>"+""XXX);

theTabContainer1.addChild(theDropDownCalc);//Add the child to teh containier

wdContext.nodeCalculation_col().currentCalculation_colElement().setAttributeValue(XXX<attribute name>,"Blank");//Set teh default value as blank

Former Member
0 Kudos

First, it does not matter where the data for the drop-down lists come from. From the view of a drop-down list, they come from the view controller context.

Next, it depends on how dynamic this must be. Is the number of drop-down lists fixed, but you just want to make the content and state dependend from the selection of another drop-down list, or do you need an arbitraty deep cascade of drop-down lists?

Armin

Former Member
0 Kudos

Thanks for reply

I strucked at the context binding itself.

I created dropdownByIndex dynamically.For this values are coming form rfc.

wdThis.wdGetDynamicMenuCompController().executeZsd_Fm_Land_Input();
IWDDropDownByIndex couDrop=(IWDDropDownByIndex)view.createElement(IWDDropDownByIndex.class,"countrydrop");
couDrop.bindTexts(wdContext.currentT_LandElement().getLandx());
theActionContainer.addChild(couDrop);

I have to bind this dropdown with the landx attribute.

How can I bind?

Rajani

Former Member
0 Kudos

Hi,

To bind to the attribute use as follows



wdThis.wdGetDynamicMenuCompController().executeZsd_Fm_Land_Input();
	  IWDDropDownByIndex couDrop=(IWDDropDownByIndex)view.createElement(IWDDropDownByIndex.class,"countrydrop");
	
	  IWDAttributeInfo attrInfo = wdContext.node_Land().getNodeInfo().getAttribute("landx");
	  couDrop.bindTexts(attrInfo);
	  theActionContainer.addChild(couDrop);

venkatakalyan_karanam
Active Contributor
0 Kudos

Hi

You can generate any number of DD with same logic Take a context attr again of type boolean and set to True in the OnSelectAction of the DropDown,

Get this boolean value in wdModifyMethod

if its true create one more DD box.

Regards

Kalyan

Former Member
0 Kudos

Thanks Kalyan,

But, using RFCs how can I?

I am using DropDownByIndex

wdThis.wdGetDynamicMenuCompController().executeZsd_Fm_State_Input();
String coubind=wdContext.currentT_LandElement().getLand1();
IWDDropDownByIndex couDrop=(IWDDropDownByIndex)view.createElement(IWDDropDownByIndex.class,"countrydrop");
couDrop.bindTexts(coubind);

I got the following exception,

com.sap.tc.webdynpro.progmodel.context.ContextException: DataNodeInfo(DynamicMenuView): unknown child node AF 

    at com.sap.tc.webdynpro.progmodel.context.Paths.followMetaPath(Paths.java:794)
    at com.sap.tc.webdynpro.progmodel.context.Paths.getAttributeInfoFor(Paths.java:234)

I have to bind with the land1 which is under T_Land node.

Thanks

Rajani

former_member201361
Active Contributor
0 Kudos

hi,

Are u sure u have binded the correct response node to the DropDownByKey(please check it).

its better that u excecute the model in the Doinit method of the controller . and do the model context mapping between the view and the Controller.

Bind the text property of the Drop down withe Correct output Model node and Attribute .

Thanks and regards

Fistae

venkatakalyan_karanam
Active Contributor
0 Kudos

Hi Rajani

Take a context attr of boolean and set this value to true in the OnSelect action of the tab.Because dynamically you can create the elements in wdDoModify method only.

In wdDoModify method get the boolean value of the context attr

like boolean tabSele = wdContext.currentContextElement().get<ContextAttr>();

if( tabSele )

{

IWDTransparentContainer cont =(IWDTransparentContainer )view.getElement(" pass the id of the container")

IWDDropDownByKey dd = view.createElement(IWDDropDownByKey.class,"DD_ID");

//add this to container

cont.addElement(dd);

//populate the values coming from RFC

}

Regards

Kalyan