簡體   English   中英

在XML表屬性(SAP UI5)中設置條件

[英]Set condition in XML table property (SAP UI5)

我想我設置的“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>

這就是我的“ changedModel”數據的樣子: 在此處輸入圖片說明

因此,“ highlight”屬性應該用於通知所需的突出顯示。

當使用上述代碼時,即使我檢查了100次語法,也出現了語法錯誤。 那是錯誤:

應該是'}',而是在表達式綁定{= $ {changedModel> highlight} =='yellow'中看到'='嗎? '警告':$ {changedModel} =='綠色'? '成功':'無'}在位置29。

我的代碼有什么問題?

樣本輸出更改數據

(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

changedModel

{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", …}

首先,請確保將compatVersion設置為edge或將綁定語法設置為complex,否則將無法使用復雜的綁定。

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

關於綁定,您在第二個條件下缺少了“亮點”。

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

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM