cancel
Showing results for 
Search instead for 
Did you mean: 

Mapping DropDownByKey to a Collection Object

i806184
Advisor
Advisor
0 Kudos

How can we map A DropDown to a Collection of Datobjects and how to get the value selected

Any help is appreciated

Accepted Solutions (0)

Answers (2)

Answers (2)

Former Member
0 Kudos

Valery,

I'm working with Vinoo on this problem at the moment and your suggestion helps us out with a couple of our problems, but I think I have a scenario where we need to use the DD by Key.

We have a model node (0..1) that is bound to an input form. One of the attributes in that node are bound to a drop down box. This means the overall node is bound to ONE model object, not a collection. If I understand the DD by index solution you suggested the node would have to be bound to a collection of objects and then the DD would happen automatically, but the rest of our input fields on that object would "switch" as well. I will also try your approach to see if I am just thinking of this incorrectly.

Thanks,

Dustin

Former Member
0 Kudos

Dustin,

Let me provide a sample to be clear.

Imaging, you have 0..1 node Employee to edit instance of employees. Employee has an attribute position (id of position), and your domain model contains Position collection as a list of all available positions.

You can follow either of ways I described:

1. Employee node contains Positions sub-node with cardinality 0..n and populated by a supply function (and NOT by any model relation). In this scenario you can use DDI and refer to position as wdContext.currentPositionElement() when necessary, including case when you need to set positionID attribute in Employee element

2. You populate valueset of position ID element with key-value pairs from Position collection (smth. like id-title). Here you will use DDK control.

Moreover, you can use input field bound to attribute with OVS provider rather then DDI/DDK. For more details please refer to https://www.sdn.sap.com/irj/servlet/prt/portal/prtroot/com.sapportals.km.docs/documents/a1-8-4/web dynpro valuehelp using object value selector.pdf

Regards,

VS

Former Member
0 Kudos

Vinoo,

First of all, why the need to use DropDownByKey (DDK) rather then DropDownByIndex (DDI). Commonly, DDK serves to selecting VALUES of attribute, and DDI -- selecting ELEMENTS of node.

If DDI is suitable for you, just bind your collection to node in context, then bind DDI "texts" property to any (preferebly, human-readable :-)attribute in this node and viola! The leadSelection element will point to your data object.

If you need DDK (realy, I do not understand why for this case), then you have to do a lot of manual work:

1. Create node attribute of type String

2. Manually populate valueset for this attribute (via getting ISimpleTypeModifiable -> SVServices -> valueset and adding pairs of UniqueKey[string]<->DisplayValue[string])

3. Bind DDK to this attribute

4. Provide OnSelect action handler

5. Get UniqueKey as attribute value in handler mentioned above and somehow apply it as selection in collection

WBR,

VS