找不到 SAPUI5 格式化程序函数

SAPUI5 formatter function not found

我知道之前有人问过这个问题 here 但答案对我没有帮助。

这是我的控制器代码:

 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);
            }
        });
       },
    });  
});

这是我的带有函数 errorStatus()

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

已找到格式化程序,所以这不是问题所在。我还在我的控制器的开头声明了格式化程序,所以这也应该没问题。另一个建议的解决方案是不带括号的函数调用。我不这样做,所以这也不是问题。

错误信息是:

formatter function .formatter.errorStatus not found

我认为您尝试绑定的方式是错误的。

在js视图下,可以绑定如下:

var rowSettingsTemplate = new sap.ui.table.RowSettings({

  highlight: {
    path: "odataDetails>ERROR_MSG",
    formatter: formatter.errorStatus
  }
});

希望这对您有所帮助。