cancel
Showing results for 
Search instead for 
Did you mean: 

Drop down list....binding item value and item text?

ChrisSolomon
Active Contributor
0 Kudos

I am on ECC6 and currently developing several interactive forms. One of our most common components is going to be an employee search of sorts. The idea is that the user will enter a search string on last name in a edit/input textbox control. When executing this event, a backend service will populate a "results" list into a drop-down control. The value of each item will be the employee user name (or ID number) but the text should be the employee's name. So for example in HTML terms we would have something like....


<option value="00010234" text="Mark Smith">

So in the form interface, I have fields EMP_UNAME (for value) and EMP_FNAME (for the text). How would I bind these to the item value and item text? I ask because I must FIRST bind a field to the drop-down itself before being able to bind the value and text. It seems that if I bind a field directly to the drop-down control, it just makes the field be both the item value and the item text. So for example of using username (EMP_UNAME) if binded to the drop-down, it would end up creating...


<option value="00010234" text="00010234">

That's not what we need or can use.

Any help?

Accepted Solutions (0)

Answers (1)

Answers (1)

ChrisSolomon
Active Contributor
0 Kudos

Figured it out.

Basically, I have a field in my form interface defined for EMP_UNAME for example. I bind this to my drop down and also change the "Specify Values" portion to set the binding there too (slightly different format than the other binding..$record.sap-vhlist.<Field name>\.DATA\.FIELD.item[*]. I then set the list item value to "key" and list text to "text".

Through configuration, I "tie" my EMP_UNAME field to a backend service. That service will actually populate the "value" with the username and the "text" with the full employee name (or whatever I want) and pass it back to the drop-down control. Soooo the user does in fact see the employee name in the drop-down but upon selecting one, they are actually sending the userID value to my bound EMP_UNAME field. Therefore, I don't even have to define a true "EMP_FNAME" field at all.

It's pretty tricky and took a bit of exploring to work out. I may blog it all soon.