cancel
Showing results for 
Search instead for 
Did you mean: 

How to place two fields as text in ComboBox

Former Member
0 Kudos

I am using a combo box for values selection and now need to display two fields as display in the dropdown for selection .

In the combobox , the States and countries are to be displayed for the user reading from the model.

JS Bin - Collaborative JavaScript Debugging

I am able to do it with one fields, but need to show up two fields

Accepted Solutions (0)

Answers (3)

Answers (3)

SergioG_TX
Active Contributor
0 Kudos

you can also have the model contain an additional property of the concatenation of the two values

Former Member
0 Kudos

We would nt like to change the model any more and achieve it from the UI5 .

SergioG_TX
Active Contributor
0 Kudos

so in ui5.. if you have a json model.. you could create an additional property concatenating those two values from the real model

former_member188585
Participant
0 Kudos

Hello Micheal,

Please check the below code for combo box having 2 values in it.

JS Bin - Collaborative JavaScript Debugging

Best regards,

seVladimirs
Active Contributor
0 Kudos

not sure if I got question correctly but maybe you can use complex bindingSyntax data-sap-ui-xx-bindingSyntax="complex" do it like this -> JS Bin - Collaborative JavaScript Debugging

santhu_gowdaz
Active Contributor
0 Kudos

Yes, in index.html if you declare data-sap-ui-xx-bindingSyntax="complex" then the text Property you can concatenate n- number of attributes.

text="{text1} {text2}"

Former Member
0 Kudos

How can i assign only the text:"Next Week" value on selection from combobox to to Input Box? Currently i am using

var ID =  sap.ui.getCore().getElementById('combobox').getValue();  which is getting both the texts instead of only one?

santhu_gowdaz
Active Contributor
0 Kudos

this.getView().byId("combobox").getSelectedKey().trim();//For Key

this.getView().byId("combobox").getSelectedItem().getText().split("-")[0].trim();//for 1st text

this.getView().byId("combobox").getSelectedItem().getText().split("-")[1].trim();//for 2nd text

former_member182862
Active Contributor
0 Kudos

HI Santhosh

Do we need do this split thingy?

Would it be better to get the binding context and get the object, then the property of the object?

Thanks

-D

santhu_gowdaz
Active Contributor
0 Kudos

Model and the properties will gives all the data.But how we will get selected text? will you please elaborate. It will helpful for me too.

former_member182862
Active Contributor
0 Kudos

something like this?

JS Bin - Collaborative JavaScript Debugging

Thanks

-D

santhu_gowdaz
Active Contributor
0 Kudos

Thanks a lot Dennis.