Skip to Content

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

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

Add comment
10|10000 characters needed 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


  • Get RSS Feed

4 Answers

  • Apr 25 at 01:00 PM

    use binding

    never go to control to get the value

    Add comment
    10|10000 characters needed characters exceeded

  • Apr 25 at 01:08 PM

    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.

    }

    Add comment
    10|10000 characters needed characters exceeded

  • Apr 26 at 02:59 AM

    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.

    Add comment
    10|10000 characters needed characters exceeded

  • Apr 25 at 12:09 PM

    Forgot to add the error in Console

    Add comment
    10|10000 characters needed characters exceeded