这里有一个关于table的openui5官方例子。
有没有办法为Table.view.xml中的表行动态设置类属性。
<ColumnListItem>
<cells>
<ObjectIdentifier
title="{Name}"
text="{ProductId}"/>
<Text
text="{SupplierName}" />
<Text
text="{Width} x {Depth} x {Height} {DimUnit}" />
<ObjectNumber
number="{WeightMeasure}"
unit="{WeightUnit}"
state="{
path: 'WeightMeasure',
formatter: 'sap.m.sample.Table.Formatter.weightState'
}" />
<ObjectNumber
number="{
parts:[{path:'Price'},{path:'CurrencyCode'}],
type: 'sap.ui.model.type.Currency',
formatOptions: {showMeasure: false}
}"
unit="{CurrencyCode}" />
</cells>
</ColumnListItem>例如:第1行
<ColumnListItem class="bg-gray">第2行
<ColumnListItem class="bg-blue">第3行
<ColumnListItem class="bg-green">以下代码不符合要求:
<ColumnListItem class="{rowStyle}">发布于 2017-05-16 12:03:44
不幸的是,“class”不能绑定到属性。但也有一些简单的替代方案。
它包括以下步骤。
https://blogs.sap.com/2016/12/02/binding-based-dynamic-background-colors-for-sap.m.table-rows/
发布于 2017-05-16 14:00:32
您可以使用格式化程序,函数将如下所示:
setColour : function(Condition){
if(Condition){
var cellId = this.getId();
$("#"+cellId).parent().parent().parent().css("background-color","Blue");
}
}您的列代码如下所示:
<Input value="{path:'Condition',formatter:'formmater_path.setColour'}" />https://stackoverflow.com/questions/43991280
复制相似问题