问题描述
我在 iReport 中遇到了条件风格的问题。我有以下 textFields ( $ {nameField} =字段值):
I have a problem with conditionalStyle in iReport. I have the following textFields (${nameField} = field value):
$ {field1} = 30      $ {FIELD2} = 40      $ {field3} = 50
$ {field4} = 23     $ {field5} = 1     $ {field6} = 45
$ {field7} = 34     $ {字段8} = 20    $ {field9} = 0
${field1}=30 ${field2}=40 ${field3}=50
${field4}=23 ${field5}=1 ${field6}=45
${field7}=34 ${field8}=20 ${field9}=0
我需要在每个textField中设置差异背景,取决于字段的值。我创建了一个新样式并设置条件:
I need set difference background in every textField depend of the value of the field. I create a new Style and set the conditions:
<style name="ColoredField">
<conditionalStyle>
<conditionExpression><![CDATA[$F{field1} == 300]]></conditionExpression>
<style mode="Opaque" backcolor="#FCFF00"/>
</conditionalStyle>
</style>
如你所见,Style只使用 $ F {field1}
,我需要制作适用于每个 textField 的动态样式(或其他东西)。
As you can see, the Style use only $F{field1}
, and I need make a dynamic style (or something), that apply to every textField.
推荐答案
你的问题不明确,你能更明确吗?
Your question is not clear, can you be more explicit ?
-
根据我的理解,每个值都意味着文本字段的特定背景,在这种情况下,您的条件样式值应该取决于变量。也许在您的风格中使用变量可以满足您的需求。
From my understanding , each value will mean a specific background for a textfield, in that case your conditional style value should depend on variable. Maybe using Variables in your style can suit your need.
在每种样式下添加多个条件样式,如下所示:
Add multiple conditional style under each style as below:
每个textField现在可以有不同的背景:
each textField can now have different background :
<style name="ColoredField">
<conditionalStyle>
<conditionExpression><![CDATA[$F{field1} == 100]]></conditionExpression>
<style mode="Opaque" backcolor="#FCFFFF"/>
</conditionalStyle>
<conditionalStyle>
<conditionExpression><![CDATA[$F{fiCeld1} == 200]]></conditionExpression>
<style mode="Opaque" backcolor="#00FF00"/>
</conditionalStyle>
<conditionalStyle>
<conditionExpression><![CDATA[$F{field1} == 300]]></conditionExpression>
<style mode="Opaque" backcolor="#FCFF00"/>
</conditionalStyle>
</style>
这篇关于使用iReport从条件设置文本字段中的背景颜色的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!