cancel
Showing results for 
Search instead for 
Did you mean: 

Binding Nested JSON Model in XML View

huibin_lau
Participant
0 Kudos

Hi Experts,

I have a nested JSON model named salesOrderModel as below and I am trying to bind it to a list in a XML view to display all the product names in the "products" array.

{
	"orders": [
		{
			"orderId": 0,
			"orderName": "Order 1",
			"products": [
				{
					"productId": 0,
					"productName": "Product 1-A"
				},
				{
					"productId": 1,
					"productName": "Product 1-B"
				},
				{
					"productId": 2,
					"productName": "Product 1-C"
				},
				{
					"productId": 3,
					"productName": "Product 1-D"
				},
				{
					"productId": 4,
					"productName": "Product 1-F"
				}
			]
		}
	]
}

I am doing the binding in the XML view as below

<View
	xmlns="sap.m"
	xmlns:layout="sap.ui.layout"
	controllerName="test.View1">
	<Page
		title="{salesOrderModel>orderName}"
		navButtonPress="onNavBack"
		showNavButton="{device>/system/phone}">
		<content>
					<List id="products" 
						items="{salesOrderModel>/orders}"
						headerText="Products">
					<items>
						<StandardListItem title="{salesOrderModel>products/productName}" 
							type="Active"
							press="onSelectionChange"/>
					</items>
				</List>
		</content>
	</Page>
</View>

The binding path at runtime is incorrect.

How can I correct the path and display the correct information? Thanks.

Regards,

Hui Bin

View Entire Topic
0 Kudos

Hi huibin.lau,

The problem is in items give it as items="{salesOrderModel>/orders/0/products}"

and in standardListItem Title give it as title="{salesOrderModel>productName}"

and all these are case-sensitive if error is coming means its because of this reason.

please let me know once you have done.