【发布时间】:2013-11-20 17:41:12
【问题描述】:
我在使用 iReport 4.1.3 时遇到了这个基本问题。我有两个表“订单”和“订单详情”。 我将购物车中的各种产品映射到 order_details 中的每个订单。例如: 在我的订单表中:
order_id
123
456
在 order_details 表中我将有:
order_id product_id
123 abc1
123 abc2
第456章
第456章 =
第456章
我在 ireport 中创建了以下 jrxml:
<?xml version="1.0" encoding="UTF-8"?>
<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="merchant_invoice" language="groovy" pageWidth="595" pageHeight="842" columnWidth="555" leftMargin="20" rightMargin="20" topMargin="20" bottomMargin="20">
<property name="ireport.zoom" value="1.0"/>
<property name="ireport.x" value="0"/>
<property name="ireport.y" value="0"/>
<parameter name="order_ids" class="java.lang.String">
<defaultValueExpression><![CDATA[]]></defaultValueExpression>
</parameter>
<queryString>
<![CDATA[select
o.order_id,od.product_id
from cscart_orders o
inner join cscart_order_details od on od.order_id=o.order_id
where o.order_id in ($P{order_ids})]]>
</queryString>
<field name="order_id" class="java.math.BigInteger"/>
<field name="product_id" class="java.math.BigInteger"/>
<group name="order_id_group" isStartNewPage="true" isReprintHeaderOnEachPage="true">
<groupExpression><![CDATA[$F{order_id}]]></groupExpression>
<groupHeader>
<band height="25">
<textField>
<reportElement x="6" y="3" width="380" height="20"/>
<textElement/>
<textFieldExpression><![CDATA["header for order_id "+$F{order_id}]]></textFieldExpression>
</textField>
</band>
</groupHeader>
<groupFooter>
<band height="25">
<textField>
<reportElement x="8" y="3" width="291" height="20"/>
<textElement/>
<textFieldExpression><![CDATA["Footer for order id : "+$F{order_id}]]></textFieldExpression>
</textField>
</band>
</groupFooter>
</group>
<background>
<band splitType="Stretch"/>
</background>
<detail>
<band height="30" splitType="Stretch">
<textField>
<reportElement x="8" y="4" width="270" height="20"/>
<textElement/>
<textFieldExpression><![CDATA["Products with id :"+$F{product_id}]]></textFieldExpression>
</textField>
</band>
</detail>
</jasperReport>
但是当我使用参数作为 '123,456' 预览它时,我只得到一个页面,其中仅包含第一个订单的详细信息,即订单 123。 我没有得到我在哪里做错了。 请帮忙。
【问题讨论】: