AppMaker表中的条件格式

时间:2018-09-01 08:19:12

标签: google-app-maker

在AppMaker中具有数据表,并希望根据字段值在几列中进行条件格式设置(从绿色到红色)。

例如,如果投资回报率超过40%,则为该数字添加深绿色bg,20%浅绿色,<0%红色等。

理想情况下,我想做一个像excel这样的渐变,但这可能太复杂了。任何帮助将不胜感激。

1 个答案:

答案 0 :(得分:2)

假设是一对,我猜您的列是垂直/水平/固定面板或其他类型的小部件,您可以在App Maker的属性编辑器中对其进行编辑,而ROI是数据源中的一个字段。您可以通过在“样式编辑器”中设置3个样式类来完成此操作:

.dark-green {
  background: linear-gradient(to bottom, darkgreen, green);
}
.light-green {
  background: linear-gradient(to bottom, green, lightgreen);
}
.red {
  background: linear-gradient(to bottom, darkred, red);
}

然后在窗口小部件的属性编辑器中转到“显示”-“样式”,然后按如下所示绑定样式:

@datasource.item.Percent === 0 ? 'red' : @datasource.item.Percent > 0 && @datasource.item.Percent <= 0.2 ? 'light-green' : @datasource.item.Percent > 0.2 ? 'dark-green' : ''

您可以使用CSS作为背景,一旦有了类和样式的绑定,就可以找到想要的外观。

要将此概念应用于整个表行并仍然包括“ app-ListTableRow”和“ hoverAncestor”样式,则可以按以下方式绑定表行样式:

@datasource.item.Percent === 0 ? ['red','app-ListTableRow','hoverAncestor'] : @datasource.item.Percent > 0 && @datasource.item.Percent <= 0.2 ? ['light-green','app-ListTableRow','hoverAncestor'] : @datasource.item.Percent > 0.2 ? ['dark-green','app-ListTableRow','hoverAncestor'] : ['app-ListTableRow','hoverAncestor']