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

na_4

Members
  • Posts

    1
  • Joined

  • Last visited

 Content Type 

Profiles

Forum

Events

Featured Visualizations

Knowledge Base

Documentation (PDF Downloads)

Blog

Documentation (Test Area)

Documentation

Dr. Jaspersoft Webinar Series

Downloads

Everything posted by na_4

  1. I have a JSON source and want to create a main report (project data) containing a subreport (routes data). The routes subreport will contain another subreport (tasks data). I can't seem to get the routes subreport showing in the main report. Both the main report and the routes sub report show the correct data from the JSON source when I run the individually. But when I run the main report it doesn't show the sub report with the routes data. Here's what my JSON source looks like: { "project": { "id": "1f76cc5e-099e-4f29-a682-05797935d389", "project_name": " 8/09-099e", "routes": [ { "number": 1, "vehicle_id": "892b668d-4b7d-4fb6-b522-3c964a65d524", "color": "#e6194b", "driver_name": "JANE DOE", "transport_time": 15026.1, "distance": 280.18870000000004, "tasks": [ { "type": "delivery", "arrival_time": "9:015", "end_time": "9:030", "location_id": "30", "id": "f194aeae-1181-40a2-9787-6b3c8deb5f2e", "address": "Downroad 162, Ridderkerk", "distance": 10259.5, "driving_time": 958.3, "duration": 15.0, "customer_name": "AWESOME COMPANY B.V.", "street": "Downroad", "house_number": "162", "house_number_suffix": "", "city": "Ridderkerk", "notes": "Linksachter in de kantine plaatsen", "priority": "regular", "optimized_index": 1, "product_a": null, "product_b": null, "product_c": null, "product_d": null, "product_e": null, "product_f": null, "product_g": null, "product_h": null } ] }, { "number": 2, "vehicle_id": "e922e60b-6b33-45ef-b727-d73344650c6b", "color": "#3cb44b", "driver_name": "PIET HEIJN", "transport_time": 7975.3, "distance": 106.46039999999999, "tasks": [ { "type": "delivery", "arrival_time": "9:03", "end_time": "9:05", "location_id": "8", "id": "6e569637-06eb-4163-a625-1718e80d13cf", "address": "Wolfstreet 28, Ridderkerk", "distance": 3930.1, "driving_time": 336.1, "duration": 15.0, "customer_name": "COOL COMPANY", "street": "Wolfstreet", "house_number": "28", "house_number_suffix": "", "city": "Ridderkerk", "notes": "half 9 open. De kist linksachter in de keuken plaatsen", "priority": "regular", "optimized_index": 2, "product_a": null, "product_b": null, "product_c": null, "product_d": null, "product_e": null, "product_f": null, "product_g": null, "product_h": null } ] } ] }}[/code]This is what my main report (project info) looks like: <?xml version="1.0" encoding="UTF-8"?><!-- Created with Jaspersoft Studio version 6.4.0.final using JasperReports Library version 6.4.1 --><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="Simple_Blue" pageWidth="595" pageHeight="842" columnWidth="535" leftMargin="20" rightMargin="20" topMargin="20" bottomMargin="20" uuid="b25cdf78-7762-4ad1-8e97-9556d2652060"> <property name="com.jaspersoft.studio.data.defaultdataadapter" value="JsonDataAdapter.xml" /> <subDataset name="Routes" uuid="d9ad093b-81f4-4950-9b64-8b61f887ea4e"> <property name="com.jaspersoft.studio.data.defaultdataadapter" value="JsonDataAdapter.xml" /> <queryString language="json"><![CDATA[project.routes]]></queryString> <field name="number" class="java.lang.String"> <property name="net.sf.jasperreports.json.field.expression" value="number" /> <fieldDescription><![CDATA[number]]></fieldDescription> </field> <field name="vehicle_id" class="java.lang.String"> <property name="net.sf.jasperreports.json.field.expression" value="vehicle_id" /> <fieldDescription><![CDATA[vehicle_id]]></fieldDescription> </field> <field name="color" class="java.lang.String"> <property name="net.sf.jasperreports.json.field.expression" value="color" /> <fieldDescription><![CDATA[color]]></fieldDescription> </field> <field name="driver_name" class="java.lang.String"> <property name="net.sf.jasperreports.json.field.expression" value="driver_name" /> <fieldDescription><![CDATA[driver_name]]></fieldDescription> </field> <field name="transport_time" class="java.lang.Integer"> <property name="net.sf.jasperreports.json.field.expression" value="transport_time" /> <fieldDescription><![CDATA[transport_time]]></fieldDescription> </field> <field name="distance" class="java.lang.String"> <property name="net.sf.jasperreports.json.field.expression" value="distance" /> <fieldDescription><![CDATA[distance]]></fieldDescription> </field> <field name="tasks" class="java.lang.String"> <property name="net.sf.jasperreports.json.field.expression" value="tasks" /> <fieldDescription><![CDATA[tasks]]></fieldDescription> </field> </subDataset> <subDataset name="Tasks" uuid="6a88e45c-2e9d-439a-9641-7954281c1993"> <property name="com.jaspersoft.studio.data.defaultdataadapter" value="JsonDataAdapter.xml" /> <queryString language="json"><![CDATA[project.routes.tasks]]></queryString> <field name="type" class="java.lang.String"> <property name="net.sf.jasperreports.json.field.expression" value="type" /> <fieldDescription><![CDATA[type]]></fieldDescription> </field> <field name="arrival_time" class="java.lang.String"> <property name="net.sf.jasperreports.json.field.expression" value="arrival_time" /> <fieldDescription><![CDATA[arrival_time]]></fieldDescription> </field> <field name="end_time" class="java.lang.String"> <property name="net.sf.jasperreports.json.field.expression" value="end_time" /> <fieldDescription><![CDATA[end_time]]></fieldDescription> </field> <field name="location_id" class="java.lang.String"> <property name="net.sf.jasperreports.json.field.expression" value="location_id" /> <fieldDescription><![CDATA[location_id]]></fieldDescription> </field> </subDataset> <queryString language="json"><![CDATA[project]]></queryString> <field name="id" class="java.lang.String"> <property name="net.sf.jasperreports.json.field.expression" value="id" /> <fieldDescription><![CDATA[id]]></fieldDescription> </field> <field name="project_name" class="java.lang.String"> <property name="net.sf.jasperreports.json.field.expression" value="project_name" /> <fieldDescription><![CDATA[project_name]]></fieldDescription> </field> <field name="routes" class="java.lang.String"> <property name="net.sf.jasperreports.json.field.expression" value="routes" /> <fieldDescription><![CDATA[routes]]></fieldDescription> </field> <background> <band /> </background> <title> <band height="72"> <frame> <reportElement mode="Opaque" x="-20" y="-20" width="595" height="92" backcolor="#006699" uuid="181e9a87-005b-4089-bc87-2c7be1c95efa" /> <staticText> <reportElement x="395" y="43" width="180" height="20" forecolor="#FFFFFF" uuid="0efdaffc-f092-4a8f-8a4d-f8b2ec6cf839" /> <textElement textAlignment="Right"> <font size="14" isBold="false" /> </textElement> <text><![CDATA[Add a description here]]></text> </staticText> <textField> <reportElement x="20" y="20" width="234" height="43" forecolor="#FFFFFF" uuid="5f45bad5-9d91-4f0f-86a5-d8c8c27cd442"> <property name="com.jaspersoft.studio.unit.width" value="pixel" /> </reportElement> <textElement> <font size="34" isBold="true" /> </textElement> <textFieldExpression><![CDATA["Project " + $F{project_name}]]></textFieldExpression> </textField> </frame> </band> </title> <pageHeader> <band height="13" /> </pageHeader> <columnHeader> <band height="25"> <line> <reportElement x="-20" y="20" width="595" height="1" forecolor="#666666" uuid="82bd9b29-60af-4a26-b51e-e17a1812a855" /> </line> <staticText> <reportElement mode="Opaque" x="0" y="0" width="370" height="20" forecolor="#006699" backcolor="#E6E6E6" uuid="e31ecff4-cdc0-471e-afe5-ded80fa73367" /> <textElement textAlignment="Left"> <font size="14" isBold="true" /> </textElement> <text><![CDATA[id]]></text> </staticText> <staticText> <reportElement mode="Opaque" x="370" y="0" width="185" height="20" forecolor="#006699" backcolor="#E6E6E6" uuid="69acb809-d880-43b8-8f24-98bdcd244bef" /> <textElement textAlignment="Left"> <font size="14" isBold="true" /> </textElement> <text><![CDATA[project_name]]></text> </staticText> </band> </columnHeader> <detail> <band height="226"> <line> <reportElement positionType="FixRelativeToBottom" x="0" y="19" width="555" height="1" uuid="68a7cd6a-43c7-4a3c-93fe-a32436ed5589" /> </line> <textField isStretchWithOverflow="true"> <reportElement x="0" y="0" width="370" height="20" uuid="73fb7014-00bd-47fe-8624-46076a367700" /> <textElement> <font size="14" /> </textElement> <textFieldExpression><![CDATA[$F{id}]]></textFieldExpression> </textField> <textField isStretchWithOverflow="true"> <reportElement x="370" y="0" width="185" height="20" uuid="d6370e7f-7b1d-44be-8928-5c240804bba6" /> <textElement> <font size="14" /> </textElement> <textFieldExpression><![CDATA[$F{project_name}]]></textFieldExpression> </textField> <subreport> <reportElement x="0" y="19" width="555" height="207" uuid="0e5f93b0-ab4d-4538-ac8f-3c10b85e36e2" /> <parametersMapExpression><![CDATA[$P{REPORT_CONTEXT}]]></parametersMapExpression> <connectionExpression><![CDATA[$P{REPORT_CONNECTION}]]></connectionExpression> <subreportExpression><![CDATA["Simple_Blue_Routes.jasper"]]></subreportExpression> </subreport> </band> </detail> <columnFooter> <band /> </columnFooter> <pageFooter> <band height="24"> <property name="com.jaspersoft.studio.unit.height" value="pixel" /> <textField> <reportElement mode="Opaque" x="0" y="0" width="515" height="13" backcolor="#E6E6E6" uuid="f347cc44-537b-46d7-9587-f83b39b6441f" /> <textElement textAlignment="Right" /> <textFieldExpression><![CDATA["Page "+$V{PAGE_NUMBER}+" of"]]></textFieldExpression> </textField> <textField evaluationTime="Report"> <reportElement mode="Opaque" x="515" y="0" width="40" height="13" backcolor="#E6E6E6" uuid="38ae81dd-d835-49e2-8a2a-ab4bde22a5fb" /> <textFieldExpression><![CDATA[" " + $V{PAGE_NUMBER}]]></textFieldExpression> </textField> <textField pattern="EEEEE dd MMMMM yyyy"> <reportElement x="0" y="0" width="100" height="13" uuid="6361bfd9-baa8-4638-9530-cc888fc7a6ee" /> <textFieldExpression><![CDATA[new java.util.Date()]]></textFieldExpression> </textField> </band> </pageFooter> <summary> <band /> </summary></jasperReport>[/code]And this is what my first subreport (routes data) looks like: <?xml version="1.0" encoding="UTF-8"?><!-- Created with Jaspersoft Studio version 6.4.0.final using JasperReports Library version 6.4.1 --><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="Simple_Blue_Routes" pageWidth="595" pageHeight="842" columnWidth="535" leftMargin="20" rightMargin="20" topMargin="20" bottomMargin="20" uuid="7dc840bb-93d3-4adc-8c15-67966f7bf1ea"> <property name="com.jaspersoft.studio.data.defaultdataadapter" value="JsonDataAdapter.xml" /> <queryString language="JSON"><![CDATA[project.routes]]></queryString> <field name="number" class="java.lang.String"> <property name="net.sf.jasperreports.json.field.expression" value="number" /> <fieldDescription><![CDATA[number]]></fieldDescription> </field> <field name="vehicle_id" class="java.lang.String"> <property name="net.sf.jasperreports.json.field.expression" value="vehicle_id" /> <fieldDescription><![CDATA[vehicle_id]]></fieldDescription> </field> <field name="color" class="java.lang.String"> <property name="net.sf.jasperreports.json.field.expression" value="color" /> <fieldDescription><![CDATA[color]]></fieldDescription> </field> <field name="driver_name" class="java.lang.String"> <property name="net.sf.jasperreports.json.field.expression" value="driver_name" /> <fieldDescription><![CDATA[driver_name]]></fieldDescription> </field> <field name="transport_time" class="java.lang.String"> <property name="net.sf.jasperreports.json.field.expression" value="transport_time" /> <fieldDescription><![CDATA[transport_time]]></fieldDescription> </field> <field name="distance" class="java.lang.String"> <property name="net.sf.jasperreports.json.field.expression" value="distance" /> <fieldDescription><![CDATA[distance]]></fieldDescription> </field> <field name="tasks" class="java.lang.String"> <property name="net.sf.jasperreports.json.field.expression" value="tasks" /> <fieldDescription><![CDATA[tasks]]></fieldDescription> </field> <background> <band /> </background> <pageHeader> <band height="13" /> </pageHeader> <detail> <band height="41"> <line> <reportElement positionType="FixRelativeToBottom" x="0" y="19" width="555" height="1" uuid="9b65409a-2a5c-409c-9c2c-f90a3e459e2b" /> </line> <textField> <reportElement x="25" y="7" width="100" height="30" uuid="dadfa0f1-b320-4077-a797-47769bad77b9" /> <textFieldExpression><![CDATA[$F{number}]]></textFieldExpression> </textField> <staticText> <reportElement x="-75" y="7" width="100" height="30" uuid="db6ee8b5-db15-4d59-9753-eacf7a2befdd" /> <text><![CDATA[number]]></text> </staticText> <textField> <reportElement x="140" y="11" width="100" height="30" uuid="9d6460df-b499-4e47-a962-3eed922cca49" /> <textFieldExpression><![CDATA[$F{vehicle_id}]]></textFieldExpression> </textField> </band> </detail> <columnFooter> <band /> </columnFooter> <summary> <band /> </summary></jasperReport>[/code]I've tried searching this forum for answers but most of them are a few years old and they don't seem to be working for me. What am I doing wrong?
×
×
  • Create New...