XML 视图中的格式化函数 returns 错误

Formatter function in XML view returns error

我尝试根据自定义参数格式化可见性 属性。

视图中的元素定义:

<CheckBox id="compensation0" selected="false" enabled="true" 
visible="{formatter: 'my.util.Formatter.visible'}"  editable="true" select=""/>

格式化程序:

my.util.Formatter = {
    visible: function(){
        return true;
    }
};

我得到的错误:

UIComponent.js:6 未捕获错误:“[object Object]”是对象类型, 属性 "visible" 的预期布尔值 元素 sap.m.CheckBox #__xmlview1--compensationColumn

我做错了什么?

谢谢。

我不完全确定,但格式化程序不应该也期望 path 属性(不管你是否使用它)?

此外,我希望您的格式化程序是用 AMD 结构编写的:

sap.ui.define([], function () {
    "use strict";

    return {
        visible: function(value) {
            return true;
        }
    };
});

BindingParser 失败,因为您在绑定对象定义中没有路径 属性。最后,您有一个无效的布尔可见对象 属性。

您对 CheckBox 的定义包含错误:按此方式尝试:

<CheckBox id="compensation0" selected="false" enabled="true" 
visible="{path: '', formatter: 'my.util.Formatter.visible'}" editable="true" select=""/>