cancel
Showing results for 
Search instead for 
Did you mean: 

how to add values to a dropdownlist

Former Member
0 Kudos

Hi all,

i want to add values to a dropdown list at runtime not through dictionary

can anyone please help me out in this

Regards

Padma N

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

Hi padma,

U can get the selected value by the following code..

wdContext.current<node>Element().get<attribute>();

Regards,

karthik.

Answers (3)

Answers (3)

Former Member
0 Kudos

Hi padma,

To set the lead selection to zero use the code

node.setLeadSelection(IWDNode.NO_SELECTION);

<b>Difference:</b>

Dropdown by key is a UI element which is having key-value pair. You can put this key- value from the dictionary simple type.

One context variable(not a node) is sufficient to store all the values for this.

If u r using dictionary values, assign the dictionary type to this context variable.

Then bind this context variable to DrodownbyKey's Value.

For a dropdown by key, after loading the values( either from dictionary ) , if you get the value, you will be getting the key for the corresponding value.

In the same way, if u set a key present in dropdown, it will automatically display the corresponding value.

Dropdown by Index gets the value from node.There is no key-value pair. We can load the values to it in the same way we load values to a table.(ie. By from a context node)

Regards,

karthik.

Former Member
0 Kudos

Hi Karthik,

How to get the selected value if i use DropDownByIndex.

Regards

Padma N

Former Member
0 Kudos

Hi

I did not understand the step of set the leadselection to zero.

Plz give breif notes.

Thabnks&Regards

Hazrath.G

Former Member
0 Kudos

Hi padma,

u can follow like below.

In the init method u can write the following code

String s[]=new String[]

{"val1","val2",....};

Arraylist a=new Arraylist();

for(int i=0;i<s.length;i++)

{

IPrivate<ur viewname>.INodeElement ele=wdcontext.createNodeElement();

ele.set<valueattribute>(s<i>);

a.add(ele);

}

wdContext.nodeNode.bind(a);

For this in the context u can create one value attribute

Note:If ur problem will solved u can mark the question as solved

Thanks & Regards

Hazrath

Former Member
0 Kudos

Hi Hazrath ,

i did same as you told..But my dropdown list is showing empty

the code i used for dropdown is


String[] CopyData = new String[] { "Value1:", "Value2:" };
	    List copyVal = new ArrayList();
		 for (int i = 0; i < CopyData.length; ++i) {
			IPrivateNewAssembly.ICopyValuesElement MCopy =	wdContext.createCopyValuesElement();
			MCopy.setCopyValue(CopyData<i>);
			copyVal.add(MCopy);
		}
		wdContext.nodeCopyValues().bind(copyVal);

Can u plz help me out

Regards

Raghu

Message was edited by:

Raghu v

Former Member
0 Kudos

Hi

just now i cheked the same code.It works properly.

The below code i have checked

String s1[]=new String[]{"1","2","3"};

List l1=new ArrayList();

for(int i=0;i<s1.length;i++)

{

IPrivateOne.INode2Element ele=wdContext.createNode2Element();

ele.setColour(s1<i>);

l1.add(ele);

}

wdContext.nodeNode2().bind(l1);

u can attach ur texts property of Dropdown by Index ui to node.valueattribute.

Regards

Hazrath.G

Former Member
0 Kudos

Hi Hazrath,

i used DropDownByKey and i mapped the selectedKeys to the contextValue.I used the same code given y you.But data is not geting populated.

If i uesd DropdownbyIndex and by mapping context data to the texts value ,data is getting populated..but it is showing the first vaue..i dont want the firstvalue of dropdown to be visible..how to set the lead selection to zero???

wat is the diff b/w these 2??

Regards

Padma N

Message was edited by:

padma nallapati

Former Member
0 Kudos

Hi Padma,

You need to code differently for both ddk and ddi. Just assure which one you want to use.

Just try setting the lead selection to -1 and see if you can get a blank value there.

wdContext.node<nodename>().setLeadSelection(-1);

Also, if you want to use ddk then just let me know because the coding part would differ for that.

To get the selected value just use:

wdContext.node<nodename>().current<nodename>Element().get<attribute>();

Regards,

Murtuza

Former Member
0 Kudos

Hi Murtuza ,

i want to populate a dropdownbox with the data from R/3 system and retive the value selected by the user.

Can u suggest me which one means ddk or ddi to use and can u plz send me the code for these two

Regards

Padma N

Former Member
0 Kudos

Hi,

Go for drop down by index in this case.

Here, <outputnode> is the node of your RFC that holds the result and <nodename> is the node binded to your ddi.

for(int i=0; i<wdContxt.node<outputnode>().sixe();i++)

{

IPrivate<viewname>.I<nodename>Element ele = wdContext.node<nodename>().createElement();

ele.set<attribute>(wdContext.node<outputnode>().getElementAt(i).get<attribute>();

wdContext.node<nodename>().addElement(ele);

}

<b>for ddk:</b>

IWDAttributeInfo attr = wdContext.getNodeInfo().getAttribute(<attributename>);

ISimpleTypeModifiable sim = attr.getModifiableSimpleType();

IModifiableSimpleValueSet vs = sim.getSVServices().getModifiableSimpleValueSet();

for(int i=0; i<wdContxt.node<outputnode>().sixe();i++)

{

String temp = wdContext.node<outputnode>().getElementAt(i).get<attribute>();

vs.put(temp,temp);

wdContext.currentContextElement().set<attribute>(<value>); // to get initial selection.

}

Regards,

Murtuza

Message was edited by:

Murtuza Kharodawala

Abhinav_Sharma
Contributor
0 Kudos

Hi Padma,

I assume you want to add values when a user inputs something in your view. The method is same.

Put the following code onaction event of the button:

wdContext.node<urNodeName>().getNodeInfo().getAttribute(<dropdownattribut>);

IModifiableSimpleValueSet l_valueSet =

l_attInfo.getModifiableSimpleType().getSVServices().getModifiableSimpleValueSet();

for (int i = 0; i < wdContext.nodeEt_Logicalsystem().size(); i++) {

IPrivate<ViewName>View.I<input>Element inputElement =

wdContext.node<Input>().currentElement();

l_valueSet.put(inputElement.get<atrributKey>,inputElement.get<atrributValue>,);

}

Hope it helps

Thanks & Regards

Abhinav

Abhinav_Sharma
Contributor
0 Kudos

Hello Padma,

Plz delete follwoing statment. For loop is not required in ur case

for (int i = 0; i < wdContext.nodeEt_Logicalsystem().size(); i++)

Regards,

Abhinav Sharma

Former Member
0 Kudos

Hi Abhinav ,

can u please explain me clearly how to fill a dropdown with the data from R/3 system


wdContext.node<urNodeName>().getNodeInfo().getAttribute(<dropdownattribut>);

wat should be the argument for getAttribute()

Is it SVS....i dont want to show key-value pairs..i want to show only values u plz explain me clearly

Regards

Padma N

Abhinav_Sharma
Contributor
0 Kudos

Hi Padma,

If you dont want to use Key-Value then you can use DropDownByIndex. You are fetching data from R/3 and want to show it in dropdown.

You can do it like this:

1) Execute the RFC.

2) Suppose X is node and Y is its value attribute. then

List list = new ArrayList();

for(int i = 0 ; i < wdContext.node<RFC_Output>Node.size();i++){

IPrivate<ViewName>View.IXElement input = wdContext.createXElement();

input.setY(wdContext.node<RFC_Output>Node.get<RFC_Output>NodeElementAt(i).get<RFCValue>);

list.add(input);

}

wdContext.nodeX().bindElements(list);

wdContext.nodeX().setLeadSelection(1);

This way you can add the values to ur dropdown list.

Thanks & Rewards,

Abhinav

}

Message was edited by:

Armin Reichert