alexP alexP - 6 months ago 71
Javascript Question

sapui5 - Two master pages

I've got two master pages with dynamic lists.

Master Page 1:

<Page title="Title" showBackButton="true" id="master1">
<List id="idListAuctions" mode="SingleSelectMaster" select="onPressGoToMaster2" items="{auctions>/AuctionsGlobal/0/AuctionsTypes}">
<items>
<StandardListItem title="{auctions>AuctionType}" type="Navigation" />
</items>
</List>
</Page>


Master Page 2:

<List id="idListAuctionsDetail" mode="SingleSelectMaster" select="handleListSelect"
items="{AuctionTypes/Auctions}">
<items>
<StandardListItem>
<!-- Output the items from Master Page 1 -->
</StandardListItem>
</items>
</List>


My Javascript:

onPressGoToMaster2 : function(oEvent) {
console.log( oEvent.getParameter("listItem").getBindingContext() ); //undefined
this.byId("hdcSplitApp").toMaster(this.createId("master2"),'slide', oEvent.getParameter("listItem").getBindingContext());
},


My JSON File:

{
"AuctionsGlobal": [{
"AuctionsTypes": [{
"AuctionType": "Delivery",
"Auctions": [{
"AuctionID": "12345"
}, {
"AuctionID": "54321"
}]
}, {
"AuctionType": "Contract",
"Auctions": [{
"AuctionID": "98745"
}, {
"AuctionID": "56478"
}]
}]
}]
}


I want to display the items from the selected "Auction" from
master1
on my
master2
page. There seems to be no data on
master2
. I've tried so much but i don't get it.

Answer

Since you are using named model for binding list, model name should be passed to the getBindingContext as argument.

Further, use setBindingContext to set binding context of list from second master page with context obtained by getBindingContext.

Here is working example.

Comments