2016-05-11 15 views
0

私はtexfieldとラベルを持っていますが、texfieldの値に基づいてラベルの背景色を変更したいのですが、texfieldの値がnullでなければラベルのバックカラー変更する必要があります。上記ジャスパーのテキストフィールドに基づいてラベルのバックカラーを変更する方法

<style name="Color1"> 
    <conditionalStyle> 
     <conditionExpression><![CDATA[$F{check1}=="0.00"]]></conditionExpression> 
     <style mode="Opaque" backcolor="#4F110F"/> 
    </conditionalStyle> 
</style> 

<textField isBlankWhenNull="true"> 
       <reportElement x="140" y="50" width="34" height="24" backcolor="#4F110F" uuid="a792c8a7-ad7e-4f28-b8c0-cc0fce54030a"/> 
       <textFieldExpression><![CDATA[($F{check1} != null) ? $F{check1} : "0.00"]]></textFieldExpression> 
      </textField> 

ラベル

<staticText> 
       <reportElement positionType="Float" stretchType="RelativeToBandHeight" mode="Opaque" x="180" y="57" width="40" height="18" forecolor="#120808" backcolor="#FAFAFA" uuid="1f31c82f-cfca-4930-bee9-890c0dacca8d"> 
        <property name="com.jaspersoft.studio.unit.height" value="pixel"/> 
        <property name="com.jaspersoft.studio.unit.width" value="pixel"/> 
       </reportElement> 
       <box topPadding="0" leftPadding="0"> 
        <topPen lineWidth="0.0" lineStyle="Solid" lineColor="#000000"/> 
        <leftPen lineWidth="0.0" lineStyle="Solid" lineColor="#000000"/> 
        <bottomPen lineWidth="0.0" lineStyle="Solid" lineColor="#000000"/> 
        <rightPen lineWidth="0.0" lineStyle="Solid" lineColor="#000000"/> 
       </box> 
       <textElement textAlignment="Center" verticalAlignment="Middle"> 
        <font fontName="SansSerif" size="11" isBold="true"/> 
       </textElement> 
       <text><![CDATA[Yes]]></text> 
      </staticText> 
+0

可能な重複した[テキストフィールドのデータの色を変更する] (前景色)JasperReportsの条件に基づいて](http://stackoverflow.com/questions/8754448/change-text-field-data-color-foreground-color-based-on-condition-in-jasperrepo) –

答えて

0

があなたのスタティックテキスト要素に「カラー1」スタイルを適用してみテキストフィールド のための私のtexfieldの条件式であり、以下である。このような何か:

<staticText> 
    <reportElement style="Color1" positionType="Float" ... > 
     ... 
    </reportElement> 
    ... 
</staticText> 
0

まず、フォアカラー、バックカラー、モードをラベルから削除します。あなたのスタイルを追加してください。

<staticText> 
    <reportElement style="Color1" positionType="Float" stretchType="RelativeToBandHeight" x="180" y="57" width="40" height="18" uuid="1f31c82f-cfca-4930-bee9-890c0dacca8d"> 
    <property name="com.jaspersoft.studio.unit.height" value="pixel"/> 
    <property name="com.jaspersoft.studio.unit.width" value="pixel"/> 
    </reportElement> 
    <box topPadding="0" leftPadding="0"> 
    <topPen lineWidth="0.0" lineStyle="Solid" lineColor="#000000"/> 
    <leftPen lineWidth="0.0" lineStyle="Solid" lineColor="#000000"/> 
    <bottomPen lineWidth="0.0" lineStyle="Solid" lineColor="#000000"/> 
    <rightPen lineWidth="0.0" lineStyle="Solid" lineColor="#000000"/> 
    </box> 
    <textElement textAlignment="Center" verticalAlignment="Middle"> 
     <font fontName="SansSerif" size="11" isBold="true"/> 
    </textElement> 
    <text><![CDATA[Yes]]></text> 
</staticText> 

あなたの状態、$ F {CHECK1} == "0.00" が動作しない場合。 javaの.equalsプロパティを試してください。新しいBigDecimal($ F {check1})==新しいBigDecimal( "0.00")のように

関連する問題