SAPUI5 oTable one row as a link, others as textview

后端 未结 1 1071
孤城傲影
孤城傲影 2021-01-21 10:05

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 col

相关标签:
1条回答
  • 2021-01-21 10:43

    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.

    0 讨论(0)
提交回复
热议问题