找不到SAPUI5格式化程序功能

问题描述 投票:1回答:1

我知道在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个回答
1
投票

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

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

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

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

希望这可以帮助。

© www.soinside.com 2019 - 2024. All rights reserved.