Skip to Content
0

How to get Combobox selected value and create a dynamic field based on that ?

Apr 25 at 12:03 PM

52

avatar image

Hi Experts,

I have requirement where on selecting the dropdown value from the combobox i have create a lable and button dynamically.

Below is the code which i have used to get the selected value but its working

onSelect:function(){
var item = sap.ui.getCore().byId("combo");
console.log("you have selcted"+item.getSelection());
}

Can somebody help me how to get the selected values and generate the fileds dynamically ?

KR,

Anil

10 |10000 characters needed characters left characters exceeded

Hi Jun Wu,

I have managed to get the selected value using below code

var me = this;
var view = me.getView();
var value = view.byId("filtercombo").getSelectedKey();
console.log("you have selcted" + value);

Now how can i create the dynamic fields ? Please suggest


0
* Please Login or Register to Answer, Follow or Comment.

4 Answers

Jun Wu Apr 25 at 01:00 PM
0

use binding

never go to control to get the value

Share
10 |10000 characters needed characters left characters exceeded
Sharath M G Apr 25 at 01:08 PM
0

Bind a method to event "change" for the select. WHen you bind a function, include a parameter in the function.

ex: change:onChange(oEvent)

onChange: function(oEVent){

oEvent - This variable will hold selected line/item and other details.

}

Share
10 |10000 characters needed characters left characters exceeded
Jakob Marius Kjær Apr 26 at 02:59 AM
0

Use the oEvent and you can get the key by var sSelectedKey = oEvent.getSource().getSelectedKey(), or the item by var sSelectedKey = oEvent.getSource().getSelectedItem().


I believe you can even look into the oEvent parameters and get the item from there directly.

Show 1 Share
10 |10000 characters needed characters left characters exceeded

Thanks Jokob,

i am able to get the selected value now. can you please tell me how can i create the dynamic fields now ?

KR,

Anil

0
Anil Thammisetty Apr 25 at 12:09 PM
0

Forgot to add the error in Console


error.png (39.9 kB)
error.png (39.9 kB)
Share
10 |10000 characters needed characters left characters exceeded