SAPUI5 oTable 一行作为链接,其他作为文本视图 [英] SAPUI5 oTable one row as a link, others as textview

查看:47
本文介绍了SAPUI5 oTable 一行作为链接,其他作为文本视图的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

目前我有一个 sapui 表,我希望其中一行是链接,所有其他行都应该是文本视图.我的问题是,构建表是基于列:

Currently I have an sapui table, where I want to have one single row being a link, all other rows should be textviews. my problem is, that constructing the table is based on columns:

oTable.addColumn(new sap.ui.table.Column({
    label : new sap.ui.commons.Label({
        text : "Berichtsmonat",
        hAlign : sap.ui.core.HorizontalAlign.Center,
    }),
    template : new sap.ui.commons.Link({ // <-- this should only be valid
                 // for one row, others should be
                 // new sap.ui.commons.TextView
        text : "{Text01}",
        press : pressListOpen, 
    }),
    width : '120px',
    hAlign : sap.ui.core.HorizontalAlign.Center,
}));

在定义所有列之后..

oTable.bindRows("/GetXYZ");

因此,我无法将其切换为一行.我该怎么做?有可能吗?

So, I cannot switch this for one single line. How would I do this? is it possible?

我想我必须以另一种方式创建表格,但是如何?非常感谢代码示例如何解决问题或如何为我正确构建表格...

I think I have to create the table in another way, but how? Would be very thankful for code examples how to solve the problem or how to construct the table properly for my doing...

推荐答案

一种解决方案是将模板定义为 Horizo​​ntalLayout.向现有数据模型添加额外的可见性标志,例如如下 VisibleFlagForTextVisibleFlagForLink (VisibleFlagForText == !VisibleFlagForLink) .

One solution is that you define the template as a HorizontalLayout. Add additional visibility flags to your existing data model, for example as following VisibleFlagForText and VisibleFlagForLink (VisibleFlagForText == !VisibleFlagForLink) .

var oText = new sap.ui.commons.TextView({
    text:"{Text01}", 
    visible : "{VisibleFlagForText}"
});

var oLink = new sap.ui.commons.Link({ 
    text : "{Text01}",
    press : pressListOpen, 
    visible : "{VisibleFlagForLink}"
});

var oLayout = new sap.ui.layout.HorizontalLayout("Layout1",{content: [oText, oLink ]});

oTable.addColumn(new sap.ui.table.Column({
    label : new sap.ui.commons.Label({
        text : "Berichtsmonat",
        hAlign : sap.ui.core.HorizontalAlign.Center,
    }),
    template : oLayout,
    width : '120px',
    hAlign : sap.ui.core.HorizontalAlign.Center,
}));

然后您可以更新单行数据模型的可见性标志以设置链接可见或文本视图可见.

Then you can update the visibility flags of the data model of your single row to set link visible or textview visible.

这篇关于SAPUI5 oTable 一行作为链接,其他作为文本视图的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆