Skip to Content
0
May 10, 2020 at 08:43 AM

List Control not binding with JSON Model - SAPUI5

1081 Views Last edit May 10, 2020 at 08:49 AM 2 rev

Hi ,

I am using sap.m.List to display some data. The data is coming from the JSON Model, it also has data. But somehow the binding is not working and data is not displayed in the List view. Even there is no error.

purchaseHistory.view.xml

<mvc:View xmlns:core="sap.ui.core" xmlns:mvc="sap.ui.core.mvc" xmlns="sap.m"
	controllerName="novigoapplications.SuperMarket.controller.purchaseHistory" xmlns:html="http://www.w3.org/1999/xhtml">
	<App>
		<pages>
			<Page title="Title">
				<content>
					<List headerText="Purchase History"  width="60%" items="{ path: 'purchaseHistoryData>/Result' }" id="history">
						<items>
							<StandardListItem title="{purchaseHistoryData>PurchaseId}"></StandardListItem>
						</items>
					</List>
				</content>
			</Page>
		</pages>
	</App>
</mvc:View>


purchaseHistory.controller.js

sap.ui.define([
	"sap/ui/core/mvc/Controller"
], function (Controller) {
	"use strict";


	return Controller.extend("novigoapplications.SuperMarket.controller.purchaseHistory", {

		onInit: function () {
			var oModel = new sap.ui.model.odata.v2.ODataModel("/sap/opu/odata/sap/ZGW_UI5_SUPER_MARKET_SRV");
			sap.ui.getCore().setModel(oModel, "purchaseHistory");
			var model = sap.ui.getCore().getModel("purchaseHistory");
			model.setHeaders({
				"X-Requested-With": "X"
			});
			var readURL = "/CustomerSet('" + window.custid + "')/CusttopurNav";
			model.read(readURL, {
				success: function (oData, oResponse) {
					var purchaseHistoryData = new sap.ui.model.json.JSONModel({
						"Result": oData.results
					});
					sap.ui.getCore().setModel(purchaseHistoryData, "purchaseHistoryData");
				}
			});
		}
	});
});

Can anyone tell what is the error here ?

Thanks in advance.