【问题标题】:SAPUI5 formatter function not found找不到 SAPUI5 格式化程序函数
【发布时间】:2019-05-04 17:33:42
【问题描述】:

我知道在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.errorStatus

【问题讨论】:

    标签: javascript error-handling sapui5 highlight formatter


    【解决方案1】:

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

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

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

    希望这会有所帮助。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2016-10-29
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2019-10-18
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多