简体   繁体   English

如何在 ListReport 模板中实现 SAP UI5 - Cell Formatter

[英]How to implement a SAP UI5 - Cell Formatter in ListReport Template

We are using a List Report template from SAP UI5 template library for a Reporting application.我们将 SAP UI5 模板库中的 List Report 模板用于报告应用程序。

Now we are facing problem in formatting one particular cell data, which is coming from back-end xsodata service.现在我们面临格式化来自后端 xsodata 服务的特定单元格数据的问题。

Example例子
Suppose we need to show the time in HH:MM:SS (Hour:Minute:Seconds) format and we are receiving it only in form of seconds.假设我们需要以 HH:MM:SS (Hour:Minute:Seconds) 格式显示时间,而我们只以秒的形式接收它。

We have the logic to convert seconds to hours but don't know where to plugin the formatter function.我们有将秒转换为小时的逻辑,但不知道在哪里插入格式化程序功能。

If it was Smarttable or the sap.m.table, we could have mentioned this in the view itself.如果是 Smarttable 或 sap.m.table,我们可以在视图本身中提到这一点。 how to do this in List Report Template?如何在列表报告模板中执行此操作?

Any sort of help is highly appreciated.任何形式的帮助都受到高度赞赏。 Thank you in advance.先感谢您。

Try using parts , where one part will be your odata binding and in formatter use the UI5 date formatter .尝试使用部分,其中一部分将是您的 odata 绑定,并且在格式化程序中使用 UI5 日期格式化程序。 https://sapui5.hana.ondemand.com/explored_v1.html#/sample/sap.ui.core.sample.TypeDateAsDate/preview https://sapui5.hana.ondemand.com/explored_v1.html#/sample/sap.ui.core.sample.TypeDateAsDate/preview

 <Text text="{
                path: '/this_Is_the_binding',
                type: 'sap.ui.model.type.DateTime',
                formatOptions: {
                    pattern: 'yyyyMMdd HHmmss'
                }
            }" />

This can solve your issue.这可以解决您的问题。 You can add pattern as per your need您可以根据需要添加图案

我是通过为列表报告创建扩展(根据https://sapui5.hana.ondemand.com/#/topic/28e95702b5854b938ac51c4bc2d078ab的“自定义列和单元格”)并在其中设置格式化程序来实现的...

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM