cancel
Showing results for 
Search instead for 
Did you mean: 

Drop Down Binding Problem with a field within Table - UI5

former_member466137
Participant
0 Kudos
934

Hello Experts,

Not sure what's happening with this binding. I have added drop-down for one field in table. Based on another field value drop-down dynamically changes.

I have used Combo-Box event "loadItems" to read data from Backend and when trying to bind back to drop-down field it's not working...

Here is my XML View.

<ComboBox id="Mrkt" value="{Markets}" loadItems="readMarket" > </ComboBox>

JS - Read Odata and Binding wirtten on method "readMarket"

var oJsonModel = new JSONModel(); var oDropDown = this.getView().byId("Mrkt");

oModel.read("/ReadSet", {

async:false, filters:oFilters, urlParameters:{"$select": "Zmarket"},

success: function(oData, oResponse) {

oJsonModel.setData({ items : oData.results });

oDropDown.setModel(oJsonModel);

oDropDown.bindAggregation("items", "/items",

new sap.ui.core.ListItem({ text: "{Zmarket}" })

}

Here's final Debugging data.

results.png

Result looks like below

Can you tell me what i am missing.

Accepted Solutions (1)

Accepted Solutions (1)

junwu
Active Contributor
0 Kudos

var oDropDown = this.getView().byId("Mrkt"); you won't be able to get your dropdown,

that is for template, the one created for each row has different id.

Answers (1)

Answers (1)

nabheetscn
Active Contributor

Hello Hari Krishnan

Do as follow, you are providing the template in a wrong way. Check this plnkr. working with a combo.

oDropDown.bindAggregation("items", {path:"/ProductCollection",
      template:new sap.ui.core.Item({ text: "{Name}" })});

Thanks

Nabheet

former_member466137
Participant
0 Kudos

Hey Madan, Wu's finding was correct. It did work when mapped to row level.

nabheetscn
Active Contributor
0 Kudos
Hari Krishnan okay. If you check the plnkr code below it work with this also, by passing template with aggregation it does the same
   readMarket:function(oEvent){
var oDropDown = this.getView().byId("Mrkt");
oDropDown.setModel(this.getView().getModel());
oDropDown.bindAggregation("items", {path:"/ProductCollection",
      template:new sap.ui.core.Item({ text: "{Name}" })});
    },