我有以下JSON模型:
{
"Auctions": [{
"AuctionsTypes": [{
"AuctionType": "Contract",
"Auctions": [{
"AuctionID": "12345"
}, {
"AuctionID": "54321"
}]
},{
"AuctionType": "Delivery",
"Auctions": [{
"AuctionID": "12345"
}, {
"AuctionID": "54321"
}]
}]
}]
}
我的JS:
var oAuctionsModel = new sap.ui.model.json.JSONModel();
oAuctionsModel.loadData("model/mock_auction_types.json");
oView.setModel(oAuctionsModel, "auctions");
我想在列表中输出
AuctionsType
,但是此代码不起作用。列表为空。<List id="idListAuctions" items="{auctions>/Auctions/AuctionsTypes}">
<items>
<StandardListItem title="{auctions>AuctionType}" type="Navigation" press="doSomething" />
</items>
</List>
最佳答案
在您的数据中,Auctions
本身就是一个数组,因此您必须指定要访问的数组元素。
在您的示例中,第一个:
<List items="{auctions>/Auctions/0/AuctionsTypes}">
<StandardListItem title="{auctions>AuctionType}" />
</List>