Skip to Content
0
Oct 05, 2016 at 08:10 AM

sap.m.table nodata

103 Views

Hi All,

I am using northwind odata service to populate the data into sap.m.table

But ma unbale to display data into table.

am i doing anything wrong Please let me know

var oDataTable = new sap.m.Table(); oDataTable.addColumn(new sap.m.Column({header : new sap.m.Label({text : "Customer Id"})})); oDataTable.addColumn(new sap.m.Column({header : new sap.m.Label({text : "Company Name"})})); oDataTable.addColumn(new sap.m.Column({header : new sap.m.Label({text : "Contact Name"})})); oDataTable.addColumn(new sap.m.Column({header : new sap.m.Label({text : "Contact Title"})})); oDataTable.addColumn(new sap.m.Column({header : new sap.m.Label({text : "Address"})})); oDataTable.addColumn(new sap.m.Column({header : new sap.m.Label({text : "City"})})); oDataTable.addColumn(new sap.m.Column({header : new sap.m.Label({text : "Region"})})); oDataTable.addColumn(new sap.m.Column({header : new sap.m.Label({text : "Postal Code"})})); oDataTable.addColumn(new sap.m.Column({header : new sap.m.Label({text : "Country"})})); oDataTable.addColumn(new sap.m.Column({header : new sap.m.Label({text : "Phone"})})); oDataTable.addColumn(new sap.m.Column({header : new sap.m.Label({text : "Fax"})})); //var serviceUrl = "https://cors-anywhere.herokuapp.com/services.odata.org/V2/Northwind/Northwind.svc/"; var serviceUrl = "https://cors-anywhere.herokuapp.com/services.odata.org/V3/Northwind/Northwind.svc/"; var oModel = new sap.ui.model.odata.ODataModel(serviceUrl,true); sap.ui.getCore().setModel(oModel); /*var jsonModel = new sap.ui.model.json.JSONModel(); oModel.read("/Customers",null,null,true,function(oData,response){ jsonModel.setData(oData); });*/ //oDataTable.setModel(jsonModel); var template = new sap.m.ColumnListItem({}); template.addCell(new sap.m.Text({text : "{CustomerID}"})); template.addCell(new sap.m.Label({text : "{}"})); template.addCell(new sap.m.Label({text : "{}"})); template.addCell(new sap.m.Label({text : "{}"})); template.addCell(new sap.m.Label({text : "{}"})); template.addCell(new sap.m.Label({text : "{}"})); template.addCell(new sap.m.Label({text : "{}"})); template.addCell(new sap.m.Label({text : "{}"})); template.addCell(new sap.m.Label({text : "{}"})); template.addCell(new sap.m.Label({text : "{}"})); template.addCell(new sap.m.Label({text : "{}"})); //oDataTable.setModel(oModel); oDataTable.bindItems("/Customers",template);

Regards,

Shekar