如何在 SAPUI5 表中打印总表行 [英] How to print total table row in SAPUI5 table

查看:36
本文介绍了如何在 SAPUI5 表中打印总表行的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试这个示例,我必须添加产品总数,即屏幕上显示的总表行数.

I am trying this example in this I have to add total product count number i.e. total table rows display on screen.

https://sapui5.netweaver.ondemand.com/sdk/explored.html#/sample/sap.m.sample.Table/preview

当我尝试访问 JSON 对象的长度时,即:

When I try to Access length of JSON object i.e.:

<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 不是渲染错误:

I get SAPUI5 is not render error:

未捕获的类型错误:无法读取未定义的属性长度"

Uncaught TypeError: Cannot read property 'length' of undefined

推荐答案

我通过修改您的示例代码来回答您的问题.

I answer your question by modifying the code of your example.

  1. 编辑 Table.view.xml,在工具栏中添加一个标签.

<headerToolbar>
    <Toolbar>
        <Label text="Products"></Label>
        <Label text=""
            {
                path: '/ProductCollection',
                formatter: 'sap.m.sample.Table.Formatter.totalFormatter'
            }"">
        </Label>
    </Toolbar>
</headerToolbar>

  1. 编辑 formatter.js,添加一个方法 totalFormatter.

totalFormatter:function(results) {
    return results.length;
}

然后您将获得总表行.

基本思想是利用数据绑定的计算字段来获取结果长度.可以在此处找到该文档.

The basic idea is to utilize the Calculated Fields of Data binding to get the result length. The documentation can be found here.

这篇关于如何在 SAPUI5 表中打印总表行的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆