Im trying to bind products of certain categories, in each category there is an expand of products, first of all i list the categories from default oData service read-write only http://services.odata.org/V3/OData/OData.svc
, then by clicking the one of category im taking its path( it returns like: Category(1)
or Category(2)
and etc ), and use it to call the products of this category, but there is a mistake, Aggregation "items" does not exist in Element sap.m.StandardListItem#subcatId what im doing wrong?
here is the code that take the sPath of category then trying to retrieve the list of products of this category:
var app = sap.ui.getCore().byId("appId");
var list = sap.ui.getCore().byId("listId");
var sItem = list.getSelectedItem();
var sPath = sItem.oBindingContexts.data.sPath;
var sCont = sap.ui.getCore().byId("subcatId");
var sCats = new sap.m.StandardListItem({
parameters: {expand: "Products"},
title: "{data>Name}"
})
sCont.bindAggregation("items","data>"+sPath,sCats);
the api's:
http://services.odata.org/V3/OData/OData.svc/Categories
http://services.odata.org/V3/OData/OData.svc/Products
http://services.odata.org/V3/OData/OData.svc/Categories?$expand=Products
thank you all for help!
It seems that sCont is an instance of sap.m.StandardListItem. The StandardListItem does not have an aggregation "items" as you can see from the API docs. Instead of calling
sCont.bindAggregation("items","data>"+sPath,sCats);
you should try to bind the items aggregation of the corresponding list like this:
list.bindAggregation("items",...);
I can see in your code snippet that you even retrieved the list in the second line:
var list = sap.ui.getCore().byId("listId");