代码之家  ›  专栏  ›  技术社区  ›  sonja

在XML表属性(SAP UI5)中设置条件

  •  0
  • sonja  · 技术社区  · 6 年前

    在设置我的xml模板的“rowSettings”聚合时,我想在xml模板中设置一个条件 sap.ui.table .

    以下是迄今为止我是如何尝试的(基于我发现的其他问题):

    <table:Table id="changedData">
        <table:columns>
            <!-- Columns created in controller -->
        </table:columns>
        <table:rows>
            <!-- Rows created in controller -->
        </table:rows>
        <table:rowSettingsTemplate >
            <table:RowSettings highlight = "{= ${changedModel>highlight} == 'yellow' ? 'Warning' : ${changedModel} == 'green' ? 'Success' : 'None'}"/>
        </table:rowSettingsTemplate>
    </table:Table>
    

    enter image description here

    因此,“highlight”属性应该通知所需的高亮显示。

    应为'}',而在表达式绑定{=${changedModel>中看到'=';highlight}=='黄色'?'警告':${changedModel}=='绿色'?'位置29处的Success':'None'}。

    我的代码怎么了?

    (3) [{…}, {…}, {…}]
    0:
    COL01: "00000000"
    COL02: "Sonja"
    COL03: "Deißenböck"
    COL04: "Studentin"
    COL05: "33403215"
    COL06: "Hochschule München"
    COL07: "Teststraße 2"
    COL08: "20160115"
    COL09: " 120.00 € "
    highlight: "yellow"
    __proto__: Object
    1:
    COL01: "00000001"
    COL02: "Leon"
    COL03: "Maschine"
    COL04: "Student"
    COL05: "57945612"
    COL06: "TUM"
    COL07: "Teststraße 3"
    COL08: "20160116"
    COL09: " 160.00 € "
    highlight: "yellow"
    __proto__: Object
    2:
    COL01: "00000002"
    COL02: "Sabine"
    COL03: "Betrieb"
    COL04: "Studentin"
    COL05: "45613789"
    COL06: "LMU"
    COL07: "Teststraße 4"
    COL08: "20160117"
    COL09: " 200.00 € "
    highlight: "yellow"
    __proto__: Object
    

    更改模型

    {columns: Array(10), rows: Array(7)}
    columns: Array(10)
    0: {columnId: "COL01"}
    1: {columnId: "COL02"}
    2: {columnId: "COL03"}
    3: {columnId: "COL04"}
    4: {columnId: "COL05"}
    5: {columnId: "COL06"}
    6: {columnId: "COL07"}
    7: {columnId: "COL08"}
    8: {columnId: "COL09"}
    9: {columnId: "highlight"}
    length: 10
    __proto__: Array(0)
    rows: Array(7)
    0: {COL01: "00000000", COL02: "Sonja", COL03: "Deißenböck", COL04: "Studentin", COL05: "33403215", …}
    1: {COL01: "00000001", COL02: "Leon", COL03: "Maschine", COL04: "Student", COL05: "57945612", …}
    2: {COL01: "00000002", COL02: "Sabine", COL03: "Betrieb", COL04: "Studentin", COL05: "45613789", …}
    
    1 回复  |  直到 6 年前
        1
  •  1
  •   Daniel Almeida    6 年前

    首先确保将compatVersion设置为edge或将绑定语法设置为complex,否则将无法使用complex绑定。

    data-sap-ui-compatVersion="edge"
    data-sap-ui-xx-bindingSyntax="complex"
    

    关于绑定,您缺少一个“>在第二个条件中突出显示“1”。

    <table:RowSettings highlight = "{= ${changedModel>highlight} === 'yellow' ? 'Warning' : ${changedModel>highlight} === 'green' ? 'Success' : 'None'}"/>