Skip to Content
avatar image
Former Member

Unable to load data from Sample oData service in Ui5

Hello All,

I am trying to load sample oData service in my program

Sample oData

but when i am trying it is not getting load in my Table that is in my View.

view1.view.xml


<mvc:View controllerName="oData_Table.controller.View1" xmlns:html="http://www.w3.org/1999/xhtml" xmlns:mvc="sap.ui.core.mvc"
	displayBlock="true" xmlns="sap.m">
	<App>
		<pages>
			<Page title="{i18n>title}">
				<content>
					<Table id="idProductsTable" inset="false" items="{oModel>/PersonDetails}" >
						<headerToolbar>
							<Toolbar>
								<Title text="Student Info" level="H2"/>
							</Toolbar>
						</headerToolbar>
						<columns>
							<Column width="12em">
								<Text text="Person ID"/>
							</Column>
							<Column minScreenWidth="Tablet" demandPopin="true">
								<Text text="Age"/>
							</Column>
							<Column minScreenWidth="Tablet" demandPopin="true" hAlign="Right">
								<Text text="Phone"/>
							</Column>
							<Column minScreenWidth="Tablet" demandPopin="true" hAlign="Center">
								<Text text="Zipcode"/>
							</Column>
						</columns>
						<items>
							<ColumnListItem>
								<cells>
									<ObjectIdentifier title = "{oModel>PersonId}" />
									<ObjectIdentifier title = "{oModel>Age}" />
									<ObjectIdentifier title = "{oModel>Phone}" />
									<ObjectIdentifier title = "{oModel>Address/ZipCode}" />
								</cells>
							</ColumnListItem>
						</items>
					</Table>
				</content>
			</Page>
		</pages>
	</App>
</mvc:View>

And code for view1.controller.js

sap.ui.define([
	"sap/ui/core/mvc/Controller",
	"sap/ui/model/json/JSONModel",
	"sap/ui/model/odata/ODataModel"
], function(Controller, JSONModel, ODataModel ) {
	"use strict";


	return Controller.extend("oData_Table.controller.View1", {
	onInit: function() {


			// var oModel = new JSONModel();
			
			var oModel = new ODataModel("http://services.odata.org/V3/OData/OData.svc/", true);
			//oModel.loadData("http://services.odata.org/V3/OData/OData.svc/");
			//var jModel = new JSONModel(oModel);
			this.getView().setModel(oModel, "oModel");
		}
	});
});

What i need to do is.

  1. Loading "http://services.odata.org/V3/OData/OData.svc/" this data .
  2. Adding data it in table

Please Help me to solve this.

Best regards,

Urvish Panchal

Add comment
10|10000 characters needed characters exceeded

  • Get RSS Feed

1 Answer