Jump to content
We've recently updated our Privacy Statement, available here ×

Use the value of a parameter in a style tag


jack.bracey_1

Recommended Posts

I am looking for the ability to use the value of a parameter passed into the report to be used as the hex colour value of the background in a conditional style, does anyone know how to achieve this?

My code so far:

<style name="Parameterised Text Colour">
        <conditionalStyle>
            <conditionExpression><![CDATA[$P{styling}!=null]]></conditionExpression>
            <style backcolor={$P{style}}/>
        </conditionalStyle>
        <conditionalStyle>
            <conditionExpression><![CDATA[$P{styling}==null]]></conditionExpression>
            <style backcolor="#000000"/>
        </conditionalStyle>
    </style>

Any help is greatly appreciated

Link to comment
Share on other sites

  • Replies 1
  • Created
  • Last Reply

Top Posters In This Topic

Top Posters In This Topic

As far as I know the color attributes are just static ones.... so you can't set these to a dynamic value concerning at a parameter or even a field expression.

I created a java "PreProcessor" when loading the jrxml (per JasperAPI) and changed the style colors per JRDesignAPI (so e.g. each month could have another color defined by the user. so I created 12 styles per API and set the style background-color to the database value, afterwards I recompile the (changed) design and pass this to the normal fill manager. Works fine for my purose. :-) Perhaps just an idea for your solution (if you also call your reports from a java application)

hth + regards

C-Box

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×
×
  • Create New...