Set background color in textfield from condition using iReport

后端 未结 3 1513
情话喂你
情话喂你 2021-01-20 03:57

I have a problem with conditionalStyle in iReport. I have the following textFields (${nameField} = field value):

${field1}=30   

相关标签:
3条回答
  • 2021-01-20 04:21

    I could not find a direct way to accomplish this task - you have to create a separate style for each field.

    Considering this you can concentrate your effort on creating a small script that replicate the XML with the same stile for the fields you have. Then you can just copy/paste the XML into the report source file. Each time you need to change the style you will have to go back to your XML generator.

    0 讨论(0)
  • 2021-01-20 04:29

    Your question is not clear, can you be more explicit ?

    1. 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.

    2. Add multiple conditional style under each style as below:

    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>
    
    0 讨论(0)
  • 2021-01-20 04:30

    Try ths one :

    <style name="myStyle" fontName="Arial">
        <conditionalStyle>
            <conditionExpression><![CDATA[new Boolean($V{SANCTION_AMOUNT_MEASURE}.intValue() == 100)]]></conditionExpression>
            <style forecolor="#FF0000" isBold="true"/>
        </conditionalStyle>
        <conditionalStyle>
            <conditionExpression><![CDATA[new Boolean($V{SANCTION_AMOUNT_MEASURE}.intValue() == 200)]]></conditionExpression>
            <style forecolor="#00FF00" isBold="true"/>
        </conditionalStyle>
        <conditionalStyle>
            <conditionExpression><![CDATA[new Boolean($V{SANCTION_AMOUNT_MEASURE}.intValue() == 300)]]></conditionExpression>
            <style forecolor="#0000FF" isBold="true"/>
        </conditionalStyle>
    </style>
    
    0 讨论(0)
提交回复
热议问题