Quantcast
Channel: SCN : All Content - SAPUI5 Developer Center
Viewing all articles
Browse latest Browse all 6178

Bind a collection within odata result

$
0
0

Hi all,

 

is it possible to bind a collection within an odata result e.g. to a combobox, table etc?

 

I have the following code

 

var oModel = new sap.ui.model.odata.ODataModel("/odata");

sap.ui.getCore().setModel(oModel);

OData.read("/odata/DOM_PageInit", function (response) {

  var oItemTemplate = new sap.ui.core.ListItem({

  text: "{BuildingExtended}",

  });

  var oComboBox = new sap.ui.commons.ComboBox();

  oComboBox.bindItems(response.BuildingList, oItemTemplate);

  sap.ui.getCore().getControl("MyMatrix").createRow(new sap.ui.commons.Label({ text: "TestCombo", width: "100px" }), oComboBox);

}, function () {

  alert("Read failed");

});

 

which results in the following output

 

{

  "BuildingList":[

    {

      "BuildingID":3,"Global_Application_Userrole_ID":7,"UserRoleName":"Advanced Operator","BuildingExtended":"Extended Building 1"

    },{

      "BuildingID":47,"Global_Application_Userrole_ID":7,"UserRoleName":"Advanced Operator","BuildingExtended":"Extended Building 2"

    },{

      "BuildingID":9,"Global_Application_Userrole_ID":7,"UserRoleName":"Advanced Operator","BuildingExtended":"Extended Building 3"

    }

  ],

  "UserID":"MyUserid",

  "UserDisplayName":"Lastname, Name"

}

 

and want to bind the BuildingList collection to the oComboBox, but I always get the error "Missing template or factory function for aggregation items of Element".

 

Any help is appreciated.

 

Thanks,

Oliver


Viewing all articles
Browse latest Browse all 6178

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>