Skip to Content
avatar image
Former Member

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.

Add comment
10|10000 characters needed characters exceeded

  • Follow
  • Get RSS Feed

1 Answer

  • Nov 02, 2015 at 06:25 AM

    Hi Konstantin,

    S1:

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


    Could you please change the request url to: proxy/http://services.odata.org/V4/Northwind/Northwind.svc/

    S2:

    Goto Console---->type sap.ui.getCore().getModel("product");

    Thanks,

    KA


    Add comment
    10|10000 characters needed characters exceeded