Skip to Content
0
Jun 20, 2016 at 09:39 AM

Populating combobox from oData service.

349 Views

Hi Guys,

I am trying to populate Combobox in my Fragment pop-up from oData service.

Model.Js

getPlantModel: function(vController, entitySet, filter, modelName) {

var mainDataModel = this.mainDataModel();

var oModel = new sap.ui.model.json.JSONModel();

mainDataModel.read(entitySet+filter, {

success: function(data, response) {

oModel.setData({

listitems: data.results

});

/* vController.getView().setModel(oModel, modelName);*/

},

error: function(oError) {

vController.getView().setModel(oModel, modelName);

/*do nothing yet return empty model*/

}

});

},

View.Controller.js

var vController = this;

var qryFilter = "";

this.router = sap.ui.core.UIComponent

.getRouterFor(this);

this.router

.attachRoutePatternMatched(

this._handleRouteMatched,

this);

// Bundle F4 Help

// qryFilter = "?$filter=IvBundle eq 'X' and IvEqunr eq ''&$format=json";

models.getPlantModel(vController,

'ETS_PLANT', qryFilter,

"plantF4Model");

var oItem = new sap.ui.core.Item({

text: "{Zzpname}",

key: "{Zzwerks}"

});

var oComboBox = this.getView().byId("plantComboBox");

oComboBox.bindItems("plantF4Model", oItem);

--------------------------------------------------------------------------------

When I try to get reference to Combobox.. t

var oComboBox = this.getView().byId("plantComboBox");


oComboBox returns undefined.


any idea how this can be solved.



Thanks

Sam