我有两个带有动态列表的母版页。
母版页 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>
母版页2:
<List id="idListAuctionsDetail" mode="SingleSelectMaster" select="handleListSelect"
items="{AuctionTypes/Auctions}">
<items>
<StandardListItem>
<!-- Output the items from Master Page 1 -->
</StandardListItem>
</items>
</List>
我的 JavaScript:
onPressGoToMaster2 : function(oEvent) {
console.log( oEvent.getParameter("listItem").getBindingContext() ); //undefined
this.byId("hdcSplitApp").toMaster(this.createId("master2"),'slide', oEvent.getParameter("listItem").getBindingContext());
},
我的 JSON 文件:
{
"AuctionsGlobal": [{
"AuctionsTypes": [{
"AuctionType": "Delivery",
"Auctions": [{
"AuctionID": "12345"
}, {
"AuctionID": "54321"
}]
}, {
"AuctionType": "Contract",
"Auctions": [{
"AuctionID": "98745"
}, {
"AuctionID": "56478"
}]
}]
}]
}
我想在我的 master2
页面上显示 master1
中所选“拍卖”中的元素。 master2
上似乎没有数据。我已经尝试了很多,但我不明白。
最佳答案
由于您使用命名模型作为绑定(bind)列表,因此模型名称应传递到 getBindingContext
作为参数。
此外,使用setBindingContext
使用通过 getBindingContext
获取的上下文设置第二个母版页中的列表的绑定(bind)上下文。
Here是工作示例。
关于javascript - sapui5 - 两个母版页,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37497693/