Skip to Content
avatar image
Former Member

Can't bind oData service to select element


I am new to UI5 and after having searched a lot, I cant find a solution to bind the oData service to a select element in my code. The requirement is to get the input from the first drop-down to filter second drop-down. The first dropdown workd perfectly fine.

The second dropdown seems to not bind the items to the element.

First Dropdown view.xml

Second dropdown view.xml

controller.js (first approach)

Second approach

I am not sure what am I missing here but both the approach doesn't work. Could you please let me know what is missing?



firstapproach.png (19.1 kB)
jsonmodel.png (2.6 kB)
subcat.png (30.7 kB)
Add comment
10|10000 characters needed characters exceeded

  • Get RSS Feed

3 Answers

  • Best Answer
    avatar image
    Former Member
    Oct 27, 2017 at 10:56 AM


    This is now fixed. I used the following approach and it worked


    var oItemSelectTemplate = new sap.ui.core.Item({ key : "{ProdCategory}:"+"{Subcategory}", text : "{Description}" }); this._oView.byId("idSIssSubCat").bindAggregation("items","/results",oItemSelectTemplate);

    var sServiceUrl = this._oComponent.getMetadata().getConfig().serviceConfig.serviceUrl;

    var oConfig = {

    metadataUrlParams: {},

    json: true,

    // loadMetadataAsync : true,

    defaultBindingMode: "TwoWay",

    defaultCountMode: "Inline",

    useBatch: false


    this.oDataModel = new sap.ui.model.odata.ODataModel(sServiceUrl, oConfig);

    var that = this;

    var uri = "/IssueSubCategorySet?$filter=ProdCategory eq '" + oEvent.getSource().getSelectedItem().getKey() + "'";,

    { success : function(oData)

    { that.oIssueCategoryModel.setData(oData);"Success!");


    error : function(oError)




    async : false


    Add comment
    10|10000 characters needed characters exceeded

  • Oct 05, 2017 at 10:48 PM

    Hi There,

    In your first approach, change the code to:

      filters:[new sap.ui.model.filter.Filter({path:'ProdCategory',operator:'EQ',value1:oEvent.getSource().getSelectedKey()],

    This should correctly encode the service URL and should work. bindAggregation should also work if you use filters array in binding and not appending "$filter" directly to URL.

    Add comment
    10|10000 characters needed characters exceeded

    • Former Member


      Thanks for your reply. I tried both bindItems and bindAggregation with the filters array, the service is not called at all. The control doesn't reach the service I developed.



  • Oct 10, 2017 at 09:07 AM

    Consider your select is in the fragment :

    <Select change="selectChange" showSecondaryValues="true">

    Now from your controller you can bind the model values like this:

    var mModel = new sap.ui.model.json.JSONModel(); //initialise your model from a JSON file
    				var oItemSelectTemplate = new sap.ui.core.Item({
    				            key : "{Userid}",
    				            text : "{Userid}"
    				        }); //Define the template for items, which will be inserted inside a select element
    				var mySelectMenu = this.oDialogFragment.getContent()[0].getContent()[2]; //Get a reference to the UI element, Select to bind data
    				mySelectMenu.setModel(mModel);// set model your_data_model to Select element
    				mySelectMenu.bindAggregation("items","/results",oItemSelectTemplate); //bind aggregation, item to Select element with the template selected above

    Hope this helps,


    Add comment
    10|10000 characters needed characters exceeded