开发者

How can I get JasperReports to print a field every time it changes?

I am using iReport to create reports based off of an XML Data Source.

My source XML looks like this:

<Data>
  <Master>
    <ProductId>12345</ProductId>
    <Sub>
      <Id>1</Id>
      <Type>Color</Type>
      <Value>Blue</Value>
    </Sub>
    <Sub>
      <Id>2</Id>
      <Type>Color</Type>
      <Value>Red</Value>
    </Sub>
    <Sub>
      <Id>3</Id>
      <Type>Size</Type>
      <Value>XL</Value>
    </Sub>
  </Master>
</Data>

I have a master report and a subreport. In my master report, in the Detail band I 开发者_Python百科have:

Product ID and Type

Which refer to Fields:

Product ID --> Description (xPath) = ProductId
Type       --> Description (xPath) = Sub/Type

The xPath for the subreport is:

Master/Sub

What I want to happen is, I want the report to print the "Product ID and Type" row EVERY TIME THE "TYPE" CHANGES. Unfortunately, I have not found a way for this to work. I have created groups, etc,used the "Print When" expressions, but the thing REFUSES to work.

I have been working with iReports and JasperReports for almost 2 years, and while powerful, it remains poorly documented and uses arcane terminology for a lot of the variables.

So the desired effect in the output that I want is:

 12345 Color
   Blue
   Red

 12345 Size
   XL

but instead, what I end up with is:

12345 Color Blue Red XL

"Size" is skipped completely. Can anyone help?


Grouping on ProductId + Sub/Type should give you exactly what you want. You'll need to post a few more details for someone to know precisely where the problem is.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜