cancel
Showing results for 
Search instead for 
Did you mean: 

Difference b/w drop down by key & drop-down by value.....

Former Member
0 Kudos

Hi,

I would like to know the difference between Drop-down By key and Drop-down By Value.

Can i have a sample code to know what exactly the difference is.

Please help me out in this regard.

Thanks and regards.

Chandrashekar.

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

Hi,

The DropDownByIndex UI element represents a drop-down list with index-based context binding.

Use this element for realizing a one-from-many selection. The drop-down list consists of a text field, a button and a popup. The currently selected value is displayed in the text field, the list of all selectable values is displayed in the popup which is opened by pressing the button.

Data binding:

The property texts must be bound to an attribute Text having a simple type like String contained in a node Items having cardinality 0..n.

The selected item is given by the (lead) selected element of node Items, the item texts are the Text attribute values in node Items

Events:

On selection of an item, the event onSelect is triggered. Event parameter index contains the index of the newly selected item.

The DropDownByKey UI element represents a drop-down list with key-based context binding.

Use this element for realizing a one-from-many selection. The drop-down list consists of a text field, a button and a popup. The currently selected value is displayed in the text field, the list of all selectable values is displayed in the popup which is opened by pressing the button.

Data binding:

The property selectedKey must be bound to a context attribute Key having a simple type like String with a value set.

The selectable items of the drop-down list are the keys of the value set, the displayed texts are the corresponding values. The currently selected item is given by the current value of property selectedKey.

Events:

On selection of an item, the event onSelect is triggered. The event parameter key contains the key of the newly selected item.

Use the following to com.sap.dictionary.runtime.ISimpleType

com.sap.typeservices.ISimpleValueSet to populate the list.

Regards

Ayyapparaj

Answers (2)

Answers (2)

Former Member
0 Kudos
Former Member
0 Kudos

Hi,

Drop down by index will store the values in form of indexes as we have in case of an array.

Drop down by key will store values in form of key-value pair.

I have mentioned code for adding values to both at runtime:

<b>ddi</b>

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