danoldenkampgmail.com Posted May 30, 2019 Share Posted May 30, 2019 Trying to get a Style conditional expression to work for a sub data set, but it keeps saying:Report design not valid : 1. Field not found : TotalADJI copied the field to the report main datasset field, but still field not found. Link to comment Share on other sites More sharing options...
danoldenkampgmail.com Posted May 30, 2019 Author Share Posted May 30, 2019 <?xml version="1.0" encoding="UTF-8"?> <!-- Created with Jaspersoft Studio version 6.8.0.final using JasperReports Library version 6.8.0-2ed8dfabb690ff337a5797129f2cd92902b0c87b --> <jasperReport xmlns="http://jasperreports.sourceforge.net/jasperreports" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://jasperreports.sourceforge.net/jasperreports http://jasperreports.sourceforge.net/xsd/jasperreport.xsd" name="Adjustment_Report" language="groovy" pageWidth="612" pageHeight="792" whenNoDataType="AllSectionsNoDetail" columnWidth="555" leftMargin="20" rightMargin="20" topMargin="20" bottomMargin="20" isIgnorePagination="true" uuid="96cfc8bd-05ec-4abe-9f17-9c06b97d9f6d"> <property name="com.jaspersoft.studio.data.sql.tables" value=""/> <property name="com.jaspersoft.studio.data.defaultdataadapter" value="qc_emetal"/> <property name="ireport.jasperserver.url" value="http://192.168.1.118:8080/jasperserver/"/> <property name="ireport.jasperserver.user" value="jasperadmin"/> <property name="ireport.jasperserver.reportUnit" value="/reports/iMetal/QC/Customer/MONTH_END/Adjustment_Report"/> <property name="ireport.jasperserver.report.resource" value="/reports/iMetal/QC/Customer/MONTH_END/Adjustment_Report_files/main_jrxml"/> <import value="org.apache.commons.lang3.time.*"/> <style name="NegativeRed"> <conditionalStyle> <conditionExpression><![CDATA[$F{TotalADJ}<0]]></conditionExpression> <style forecolor="#ED0905" backcolor="#FFFFFF" isBold="true"/> </conditionalStyle> </style> <style name="Table_TH" mode="Opaque" backcolor="#F0F8FF"> <box> <pen lineWidth="0.5" lineColor="#000000"/> <topPen lineWidth="0.5" lineColor="#000000"/> <leftPen lineWidth="0.5" lineColor="#000000"/> <bottomPen lineWidth="0.5" lineColor="#000000"/> <rightPen lineWidth="0.5" lineColor="#000000"/> </box> </style> <style name="Table_CH" mode="Opaque" backcolor="#BFE1FF"> <box> <pen lineWidth="0.5" lineColor="#000000"/> <topPen lineWidth="0.5" lineColor="#000000"/> <leftPen lineWidth="0.5" lineColor="#000000"/> <bottomPen lineWidth="0.5" lineColor="#000000"/> <rightPen lineWidth="0.5" lineColor="#000000"/> </box> </style> <style name="Table_TD" mode="Opaque" backcolor="#FFFFFF"> <box> <pen lineWidth="0.5" lineColor="#000000"/> <topPen lineWidth="0.5" lineColor="#000000"/> <leftPen lineWidth="0.5" lineColor="#000000"/> <bottomPen lineWidth="0.5" lineColor="#000000"/> <rightPen lineWidth="0.5" lineColor="#000000"/> </box> </style> <subDataset name="Summary" uuid="d839e8a6-8eff-4d70-b595-01a13620fd7d"> <property name="com.jaspersoft.studio.data.sql.tables" value=""/> <property name="com.jaspersoft.studio.data.defaultdataadapter" value="qc_emetal"/> <queryString language="SQL"> <![CDATA[ select '-5' as "TotalADJ"]]> </queryString> <field name="TotalADJ" class="java.lang.Integer"> <property name="com.jaspersoft.studio.field.label" value="TotalADJ"/> </field> </subDataset> <queryString language="SQL"> <![CDATA[]]> </queryString> <variable name="Nothing" class="java.lang.String"> <variableExpression><![CDATA[""]]></variableExpression> </variable> <group name="Group1"> <groupExpression><![CDATA[$V{Nothing}]]></groupExpression> <groupHeader> <band height="60"> <componentElement> <reportElement style="NegativeRed" x="130" y="30" width="177" height="30" uuid="ba45256f-df4e-4834-a07e-cb91f8f6f242"> <property name="com.jaspersoft.studio.layout" value="com.jaspersoft.studio.editor.layout.VerticalRowLayout"/> <property name="com.jaspersoft.studio.table.style.table_header" value="Table_TH"/> <property name="com.jaspersoft.studio.table.style.column_header" value="Table_CH"/> <property name="com.jaspersoft.studio.table.style.detail" value="Table_TD"/> </reportElement> <jr:table xmlns:jr="http://jasperreports.sourceforge.net/jasperreports/components" xsi:schemaLocation="http://jasperreports.sourceforge.net/jasperreports/components http://jasperreports.sourceforge.net/xsd/components.xsd"> <datasetRun subDataset="Summary" uuid="1fbd8c10-bb2e-4cd5-98b8-1f86cc7c24a4"> <connectionExpression><![CDATA[$P{REPORT_CONNECTION}]]></connectionExpression> </datasetRun> <jr:column width="200" uuid="aa959662-a8b0-41c7-90e0-359f64cdad60"> <jr:detailCell style="Table_TD" height="30"> <textField> <reportElement x="0" y="0" width="200" height="30" uuid="8e27864d-bdd7-47d0-9008-18be1c73cac2"/> <textFieldExpression><![CDATA[$F{TotalADJ}]]></textFieldExpression> </textField> </jr:detailCell> </jr:column> </jr:table> </componentElement> </band> </groupHeader> <groupFooter> <band height="254"/> </groupFooter> </group> <background> <band splitType="Stretch"/> </background> </jasperReport> Link to comment Share on other sites More sharing options...
danoldenkampgmail.com Posted May 30, 2019 Author Share Posted May 30, 2019 Here is an example source. I would expect the one field to evaluate as red because it is < 0 and is class type: integer. and advanced style set to: NegativeRedThe conditional expression for style: NegativeRed is $F{TotalADJ}<0Error MessageReport design not valid : 1. Field not found : TotalADJ Link to comment Share on other sites More sharing options...
C-Box Posted May 31, 2019 Share Posted May 31, 2019 IMHO (!) the ConditionalStyles just use the MAIN DATASET attributes/fields/parameters and not any of it's SubDataSources (as this could be multiple). So I guess it's better to put your layout into a SubReport and use your SubDataSet ("Summary") as SubReport-DataSource. In the SubReport you can define your conditional styles using the fields from the "outer" SubDataSet (as this is actually now the "MainDataSet" of the SubReport) :-)hth + regardsC-Box Link to comment Share on other sites More sharing options...
danoldenkampgmail.com Posted June 6, 2019 Author Share Posted June 6, 2019 Thank you.It worked when I set it in the main dataset. Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now