Skip to Content
0
Jul 04, 2018 at 06:53 PM

xml view binding data from two entitysets

932 Views

Dear Experts,

I am working on a Master-Detail app. I have a view with list control and I am binding the same with the data from an entityset called "entityset1".

Odata-> data from the entityset1
<serialno>122333</serialno>

I do have another entityset called entityset2 in the same service.

Odata-> data from the entityset2
<hdata>isActive</hdata>

Data from above entityset2 will only be retrieved with the filter (/sap/opu/odata/sap/My_SRV/entityset2?$filter=(serialno=122333)

I am now trying to retrieve the value from the entityset2 and trying to bind it to one attribute in my list. This list is already binded with the entityset1 data.

Myview.xml.

<Listid="list"select="_handleSelect"><ObjectListItemid="MAIN_LIST_ITEM"press="_handleItemPress"title="{Name}"><attributes><ObjectAttributeid="ATTR1"text="{serialno}"/><ObjectAttributeid="ATTR2"text="{entityset2/hdata}"/></attributes></ObjectListItem></List>

Controller.js (binding using the below lines)

this.oList.bindAggregation("items",{
            path:'/entityset1',template:this.oListItem,
            filters:this.searchFilters
        });var oserialnum =this.getView().getBindingContext().getObject().serialno;var oHdata =new sap.ui.model.Filter("serialno","EQ",oserialnum);this.searchFilters =new sap.ui.model.Filter([oserialnum],true);this.oList.bindAggregation("items",{    
                    path :"/entityset2",   
                    filters :this.searchFilters
                });

However I am getting an error "Cannot read property 'getObject' of undefined" on this line "this.getView().getBindingContext().getObject().serialno".

Can someone kindly advise how to retrive the data from the entity2 and binding it to the list, ?