设置sap.ui.table
的“ rowSettings”聚合时,我想在xml模板中设置一个条件。
到目前为止,这是我尝试过的方式(基于我发现的其他问题):
<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>
因此,“ 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", …}
答案 0 :(得分:1)
首先请确保将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'}"/>