sapui5hana-xs

Binding a Drop Down in SAPUI5 to list all possible values


I've been able to successfully bind a DropDown control in SAPUI5 to list values based on one model. My questions is: how do I bind a DropDown to one model that contains all possible values and one model that contains the actual value for that record?

Example:

Table (and first Model)

Name School

John Hopkins

Mary Horner

The school column is a DropDown, if I bind the DropDown to this model these are the only two schools that show up when in actuality there are five possible schools to choose based on the following model:

Second Model

School

Thought this would be simple, but haven;t been able to figure it out or find an example with searches.


Solution

  • I am not quite sure I understand what you want to do exactly, but you can easily bind the selectedKey property to a different model than the one the items are filled from:

    I created an example for you: http://jsbin.com/qipedoyufa/12/edit?html,js,output

    It doesn't matter if the path points to the same model or a different one. I used named models and put the name of the model in front of the path, separated by ">". A Model named "x" with a path "/a/b/c" becomes "x>/a/b/c".

    Update: I think I now know what you meant, here is an example in a Table: http://jsbin.com/tefijezete/2/edit?html,js,output