简体   繁体   English

找不到 SAPUI5 格式化程序功能

[英]SAPUI5 formatter function not found

I know this question has been asked before here but the answer didn't help me.我知道这里之前已经问过这个问题但答案对我没有帮助。

This is my controller code:这是我的控制器代码:

 sap.ui.define([
        // there's more stuff importet here    
       'project/util/formatter',
    ], function (formatter ) {
       'use strict';
    return BaseController.extend('project.controller.ManualUpload', {

        formatter:formatter,

        onShowErrors: function() {
          //some other stuff happening here

        _.forEach(checkValidations, entry => {
            var errorMessage = oData[entry].ERROR_MSG;
            if(errorMessage) {
                var rowSettingsTemplate = new sap.ui.table.RowSettings({ highlight: "{ path: 'odataDetails>ERROR_MSG', formatter: '.formatter.errorStatus' }" }); 
                backendTable.setRowSettingsTemplate(rowSettingsTemplate);
            }
        });
       },
    });  
});

And this is my formatter with the function errorStatus()这是我的格式化程序,带有函数 errorStatus()

sap.ui.define(function() {
    'use strict';
    return {
            errorStatus: function(errorMessage) {
            if (_.isEmpty(errorMessage)) {
                return 'None';
            } else {
                return 'Error';
            }    
        },    
    };
});

The formatter is found so this can't be the problem.找到了格式化程序,所以这不是问题。 Also I declared the formatter in the beginning of my controller, so that should be fine, too.我也在控制器的开头声明了格式化程序,所以这也应该没问题。 Another suggested solution was the function call without parenthesis.另一个建议的解决方案是不带括号的函数调用。 I don't do this, so that can't be the problem either.我不这样做,所以这也不是问题。

The error message is:错误信息是:

formatter function .formatter.errorStatus not found未找到格式化程序函数 .formatter.errorStatus

I think the way you have attempted the binding is wrong.我认为您尝试绑定的方式是错误的。

In js view, you can bind as follows:在js视图中,可以如下绑定:

 var rowSettingsTemplate = new sap.ui.table.RowSettings({ highlight: { path: "odataDetails>ERROR_MSG", formatter: formatter.errorStatus } });

Hope this helps.希望这可以帮助。

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

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