相关疑难解决方法(0)

如何将控件引用传递给 XMLView 中的格式化程序?

在 SAPUI5 的 JSView 中,将当前控件引用传递给格式化函数非常容易:

oTable.bindItems("/rows", new sap.m.ColumnListItem({
    cells : [ new sap.m.Text().bindProperty("text", {
        parts: [
            { path: "someInteger" }
        ],
        formatter: function(iValue) { 
            var idText = this.getId(); //this references the current control
            return iValue;
        }
    })]
}));
Run Code Online (Sandbox Code Playgroud)

(当然,“简单”部分是因为this在控件的内部格式化程序函数中引用了)

但是,对于 XMLViews,我还没有设法在格式化程序函数中获取对当前控件的引用:

<Table items="{/rows}">
    <columns>
        <Column>
            <Text text="Some Integer" />
        </Column>
    </columns>
    <items>
        <ColumnListItem>
            <cells>
                <Text text="{ path : 'someInteger', formatter : '.formatCell' }" />
            </cells>
        </ColumnListItem>
    </items>
</Table>
Run Code Online (Sandbox Code Playgroud)

和格式化程序:

formatCell : function (sValue) {
    var a = this; …
Run Code Online (Sandbox Code Playgroud)

sapui5

3
推荐指数
1
解决办法
2万
查看次数

标签 统计

sapui5 ×1