Skip to Content

XML view binding issue

Hello,

I'm trying to bind data from Northwind OData service to XML view.

Here is XML definition of the list:

<List items="{path : '/Suppliers', parameters:{expand: 'Products/Category'}, filters : [{ path : 'Name', operator : 'EQ', value1 : 'Exotic Liquids' }] }">
	<CustomListItem >
		<Text text="Suppliers- {Name}"/>
		<List items="{path: 'Products', templateShareable:false}" visible="{path: 'Products', formatter: '.pathData'}">
			<ObjectListItem title="Product Name- {path: 'Name'}" intro="Product Description- {Category/Name}"/>
		</List>
	</CustomListItem>
</List>

The problem is that ObjectListItem doesn't display the relevant data (the formatter of the second List displays correct array of products).

What do I miss here?

Thank you.

Add comment
10|10000 characters needed characters exceeded

  • Follow
  • Get RSS Feed

3 Answers

  • Sep 17, 2018 at 08:31 PM

    Hi Yuri,

    'expand' should be used in the child List control here as we would like to prefetch the data from 'Category' association.
    Kindly refer the below code.

    <List
    items="{path : '/Suppliers', filters : [{ path : 'Name', operator : 'EQ', value1 : 'Exotic Liquids' }] }"> 
    <CustomListItem > <Text text="Suppliers- {Name}"/> <List items="{path: 'Products', parameters: {expand: 'Category'} }" > <ObjectListItem title="Product Name- {Name}" intro="Product Description- {Category/Name}"/> </List> </CustomListItem> </List>

    Add comment
    10|10000 characters needed characters exceeded

  • Sep 06, 2018 at 05:35 PM

    As far as I can see (if you've used the Northwind V2 example) a Supplier does not have a Name property. That's why your first Text binding is not working ;)

    You can check it out here: https://services.odata.org/V2/Northwind/Northwind.svc/Suppliers?$expand=Products&$format=json&$top=1

    {
    	"d": {
    		"results": [{
    			"__metadata": {
    				"uri": "https://services.odata.org/V2/Northwind/Northwind.svc/Suppliers(1)",
    				"type": "NorthwindModel.Supplier"
    			},
    			"SupplierID": 1,
    			"CompanyName": "Exotic Liquids",
    			"ContactName": "Charlotte Cooper",
    			"ContactTitle": "Purchasing Manager",
    			"Address": "49 Gilbert St.",
    			"City": "London",
    			"Region": null,
    			"PostalCode": "EC1 4SD",
    			"Country": "UK",
    			"Phone": "(171) 555-2222",
    			"Fax": null,
    			"HomePage": null,
    			"Products": {
    				"results": [{
    					"__metadata": {
    						"uri": "https://services.odata.org/V2/Northwind/Northwind.svc/Products(1)",
    						"type": "NorthwindModel.Product"
    					},
    					"ProductID": 1,
    					"ProductName": "Chai",
    					"SupplierID": 1,
    					"CategoryID": 1,
    					"QuantityPerUnit": "10 boxes x 20 bags",
    					"UnitPrice": "18.0000",
    					"UnitsInStock": 39,
    					"UnitsOnOrder": 0,
    					"ReorderLevel": 10,
    					"Discontinued": false,
    					"Category": {
    						"__deferred": {
    							"uri": "https://services.odata.org/V2/Northwind/Northwind.svc/Products(1)/Category"
    						}
    					},
    					"Order_Details": {
    						"__deferred": {
    							"uri": "https://services.odata.org/V2/Northwind/Northwind.svc/Products(1)/Order_Details"
    						}
    					},
    					"Supplier": {
    						"__deferred": {
    							"uri": "https://services.odata.org/V2/Northwind/Northwind.svc/Products(1)/Supplier"
    						}
    					}
    				}, {
    					"__metadata": {
    						"uri": "https://services.odata.org/V2/Northwind/Northwind.svc/Products(2)",
    						"type": "NorthwindModel.Product"
    					},
    					"ProductID": 2,
    					"ProductName": "Chang",
    					"SupplierID": 1,
    					"CategoryID": 1,
    					"QuantityPerUnit": "24 - 12 oz bottles",
    					"UnitPrice": "19.0000",
    					"UnitsInStock": 17,
    					"UnitsOnOrder": 40,
    					"ReorderLevel": 25,
    					"Discontinued": false,
    					"Category": {
    						"__deferred": {
    							"uri": "https://services.odata.org/V2/Northwind/Northwind.svc/Products(2)/Category"
    						}
    					},
    					"Order_Details": {
    						"__deferred": {
    							"uri": "https://services.odata.org/V2/Northwind/Northwind.svc/Products(2)/Order_Details"
    						}
    					},
    					"Supplier": {
    						"__deferred": {
    							"uri": "https://services.odata.org/V2/Northwind/Northwind.svc/Products(2)/Supplier"
    						}
    					}
    				}, {
    					"__metadata": {
    						"uri": "https://services.odata.org/V2/Northwind/Northwind.svc/Products(3)",
    						"type": "NorthwindModel.Product"
    					},
    					"ProductID": 3,
    					"ProductName": "Aniseed Syrup",
    					"SupplierID": 1,
    					"CategoryID": 2,
    					"QuantityPerUnit": "12 - 550 ml bottles",
    					"UnitPrice": "10.0000",
    					"UnitsInStock": 13,
    					"UnitsOnOrder": 70,
    					"ReorderLevel": 25,
    					"Discontinued": false,
    					"Category": {
    						"__deferred": {
    							"uri": "https://services.odata.org/V2/Northwind/Northwind.svc/Products(3)/Category"
    						}
    					},
    					"Order_Details": {
    						"__deferred": {
    							"uri": "https://services.odata.org/V2/Northwind/Northwind.svc/Products(3)/Order_Details"
    						}
    					},
    					"Supplier": {
    						"__deferred": {
    							"uri": "https://services.odata.org/V2/Northwind/Northwind.svc/Products(3)/Supplier"
    						}
    					}
    				}]
    			}
    		}]
    	}
    }
    
    Add comment
    10|10000 characters needed characters exceeded

  • Sep 08, 2018 at 10:15 AM

    Ok, it seems that the problem is not the bind inside the bind or the clash of property's name (as I thought) between models. It seems more like there's a problem with the returned OData format from the Northwind example.

    I've created an example project that you can easily import into your own WebIDE Full Stack.

    In the project, you have 2 different Pane.

    The first one is using /V2/Northwind/Northwind.svc as the OData service and the second one is using /V2/OData/OData.svc

    As you can see, the JSON returned by Northwind.svc is slightly different in format if compared to the OData.svc one

    Northwind.svc JSON -> https://services.odata.org/V2/Northwind/Northwind.svc/Suppliers?$expand=Products/Category&$format=json&$top=1 OData.svc JSON -> https://services.odata.org/V2/OData/OData.svc/Suppliers?$expand=Products/Category&$format=json&$top=1

    If you open the OpenUI5 Inspector you can see that there's a binding issue with the OData.svc binding

    If you look at the same binding from Northwind.svc (that works) you can see that it works correctly

    So, as a conclusion, I think that the bind inside the bind is possible and I don't think that the property name clashing is the issue. I think that the OData JSON result is the real problem here.

    You should test with a real well made OData Service and update the thread.

    If I will find another solution (with the OData.svc) I'll let you know.


    capture.png (37.0 kB)
    capture2.png (39.6 kB)
    capture3.png (37.4 kB)
    Add comment
    10|10000 characters needed characters exceeded