Skip to Content

Archived discussions are read-only. Learn more about SAP Q&A

Unable to bind data from oData service

Hello, Experts.

I am trying to bind oData service to sap.m.Table, but with no success. So far I am really lost and don't know that to do.

In Component.js i wrote following code, it does return metadata:

sap.ui.core.UIComponent.extend("test.Component",{

  metadata: {

       manifest: "json"

  },

  init: function() {

       sap.ui.core.UIComponent.prototype.init.apply(this, arguments);

       var oModel = new sap.ui.model.odata.v2.ODataModel("proxy/http/services.odata.org/V2/Northwind/Northwind.svc/", false);

       sap.ui.getCore().setModel(oModel, "products");

  }

});

Then i created a view, where i was hoping i can show data:

sap.ui.jsview("test.Absence_list", {

  getControllerName : function() {

    return "test.controller.Absence_list";

  },

  createContent : function(oController) {

  var oTable = new sap.m.Table("Test_table");

  oTable.setWidth("100%");

  var oColumn = new sap.m.Column({

  header: new sap.ui.commons.Label({text: "ID"})

  });

  oTable.addColumn(oColumn);

  var oColumn = new sap.m.Column({

  header: new sap.ui.commons.Label({text: "Name

  });

  oTable.addColumn(oColumn);

  var oItems = new sap.m.ColumnListItem();

  var oCell = new sap.m.Label({text:"{products>ID}"});

  oItems.addCell(oCell);

  var oCell = new sap.m.Label({text:"{products>Name}"});

  oItems.addCell(oCell);

  oTable.bindItems({path: "products>/Products", template: oItems});

  return oTable;

  }

})

But nothing happens, it just shows "no data".

Please, help me find a solution.

Tags:
Former Member
Not what you were looking for? View more on this topic or Ask a question