cancel
Showing results for 
Search instead for 
Did you mean: 

unable to load json data in xml view

Former Member
0 Kudos

I am new to SAPUI5, and was working on a application project in mvc format, using the Quickviewcard format for view.

When I load json data in my controller file, the application is displayed correctly as below:

But when I load the data from a separate json file,

I don't get the required output.

Here's the screenshot:

Here below is the json code:

If you see, it is displaying only until, the content of 1st element of array in 'elements' section of json

{
	"pages": [{
		"pageId": "companyPageId",
		"header": "Company info",
		"title": "Customer",
		"icon": "sap-icon://contacts",
		"groups": [{
			"heading":	"List",
				"elements": [{


										"label": "Status",
					"value": "Active",
					"elementType": "sap.m.QuickViewGroupElementType.text"
				}, {
					"label": "Role",
					"value": "Customer",
					"elementType": "sap.m.QuickViewGroupElementType.text"


				}, {
					"label": "Accountable",
					"value": "Dirk Bommelberg",
					"elementType": "sap.m.QuickViewGroupElementType.pageLink"
				}, {
					"label": "Main Contact",
					"value": "Udo Zimmermann",
					"elementType": "sap.m.QuickViewGroupElementType.pageLink"
				}, {
					"label": "Classification",
					"value": "A",
					"elementType": "sap.m.QuickViewGroupElementType.text"
				}, {
					"label": "Address",
					"value": "CA, 94102 San Francisco USA",
					"elementType": "sap.m.QuickViewGroupElementType.text"
				}, {
					"label": "Telephone",
					"value": "+001 6101 34869-0",
					"elementType": "sap.m.QuickViewGroupElementType.text"
				}]
			
		}]
	}]
}

I am using the following code to load the json in my controller.js And view file(fragment) is after that

var oModel = new JSONModel(jQuery.sap.getModulePath("sap.ui.demo.mock", "/contact.json"));
this.getView().setModel(oModel);<br>
<core:FragmentDefinition xmlns="sap.m" xmlns:core="sap.ui.core">
	<Panel id="quickViewCardContainer" width="300px" height="600px">
		<QuickViewCard id="quickViewCard" pages="{path : '/pages', templateShareable : 'true'}" afterNavigate="onNavigate">
			<QuickViewPage pageId="{pageId}"
					header="{header}"
					icon="{icon}"
					title="{title}"
					groups="{path : 'groups', templateShareable : 'true'}">
				<QuickViewGroup heading="{heading}" elements="{path : 'elements', templateShareable : 'true'}">
					<QuickViewGroupElement
							label="{label}"
							value="{value}"
							type="{elementType}"
							>
					</QuickViewGroupElement>
				</QuickViewGroup>
			</QuickViewPage>
		</QuickViewCard>
	</Panel>
</core:FragmentDefinition>

Accepted Solutions (0)

Answers (1)

Answers (1)

0 Kudos

Hello Suraj,

You must be initiating the Fragment in the controller. (sap.ui.xmlfragment) While initiating it, pass the view instance as the second parameter.

oDialog = sap.ui.xmlfragment("project.view.HelloDialog",this);