我正在尝试这个例子,在这个例子中,我必须添加总产品计数号,即在屏幕上显示的总表行。
https://sapui5.netweaver.ondemand.com/sdk/explored.html#/sample/sap.m.sample.Table/preview
当我试图访问JSON对象的长度时,即:
<headerToolbar>
<Toolbar>
<Label text="Products"></Label>
<Label text=""{ path: '/ProductCollection', formatter: 'sap.m.sample.Table.Formatter.totalFormatter' }""> </Label>
</Toolbar>
</headerToolbar>
totalFormatter:function(results) { return results.length; }我得到SAPUI5不是呈现错误:
未定义TypeError:无法读取未定义属性的“长度”
发布于 2014-08-05 03:48:55
我通过修改您示例的代码来回答您的问题。
<headerToolbar>
<Toolbar>
<Label text="Products"></Label>
<Label text=""
{
path: '/ProductCollection',
formatter: 'sap.m.sample.Table.Formatter.totalFormatter'
}"">
</Label>
</Toolbar>
</headerToolbar>totalFormatter:function(results) {
return results.length;
}然后,您将得到整个表行。
其基本思想是利用数据绑定的计算字段来获得结果长度。文档可以找到这里。
https://stackoverflow.com/questions/25113076
复制相似问题