Skip to Content
0

unable to load json data in xml view

Nov 25, 2016 at 06:48 AM

75

avatar image
Former Member

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>

1.jpg (27.2 kB)
2.jpg (14.7 kB)
10 |10000 characters needed characters left characters exceeded
* Please Login or Register to Answer, Follow or Comment.

1 Answer

Manne Prasad Dec 05, 2016 at 09:58 AM
0

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);
Share
10 |10000 characters needed characters left characters exceeded