【发布时间】:2016-04-27 11:33:02
【问题描述】:
我对 SAPUI5 很陌生。因此,我有一个场景:
主从页面(来自通过 SAP Web IDE 提供的主从模板,视图是 XML)显示来自我的模型(模拟数据)的项目。
主部分绑定到实体Interests。详细信息部分从实体Messages 获取其信息。我在它们之间有引用约束,它工作得很好。点击我的主部分中的项目会在详细信息部分的表格中显示相应的项目。
主章节列表:
<List
id="list"
items="{
path: '/InterestsSet',
sorter: {
path: 'InterestShortDescription',
descending: false
},
groupHeaderFactory: '.createGroupHeader'
}"
busyIndicatorDelay="{masterView>/delay}"
noDataText="{masterView>/noDataText}"
mode="{= ${device>/system/phone} ? 'None' : 'SingleSelectMaster'}"
growing="true"
growingScrollToLoad="true"
updateFinished="onUpdateFinished"
selectionChange="onSelectionChange">
<items>
<ObjectListItem
type="{= ${device>/system/phone} ? 'Active' : 'Inactive'}"
press="onSelectionChange"
title="{InterestShortDescription}"
number="{path :'MessagesSet', formatter:'.productCount'}">
</ObjectListItem>
</items>
</List>
主部分需要显示一个数值,该数值等于实体Messages中显示的项目总数(即等于详细信息部分中显示的行数)。经过一番研究(最终来自SAPUI5 - How to Bind Odata $count to a XML view),我了解了formatter 属性并添加了它。
我的格式化程序是这样写的:
productCount: function(oValue){
if (oValue) {
var sPath = this.getBindingContext().getPath() + '/MessagesID';
var oBindings = this.getModel().bindList(sPath);
return oBindings.getLength();
}
}
我尝试记录 oValue,但它似乎返回为 undefined。
是否有办法获取主列表中每个项目的计数。
【问题讨论】:
标签: data-binding sapui5