最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

jasper reports - jasperreports: vertical arrangement in jr:list doesn't work and results in overlapping elements - Stack

programmeradmin2浏览0评论

Using JasperReports Version 6.20.

I have two textfields that are elements in a list that I want to iterate on. One textfield should be placed under the other. But when I try to do it, they overlap each other in the report. I can't use the simple y value, because I actually want a sublist in between that grows dynamically. For simplicity sake I only show the two textfields in the xml code.

Here is the example:

<jr:list xmlns:jr="; xsi:schemaLocation=" .xsd" printOrder="Vertical">
    <datasetRun subDataset="TableGroup" uuid="28256056-95ed-4ce9-80ee-47a10ede48f1">
       <datasetParameter name="myObject">
          <datasetParameterExpression><![CDATA[$P{myObject}]]></datasetParameterExpression>
       </datasetParameter>
       <dataSourceExpression><![CDATA[new net.sf.jasperreports.engine.data.JRBeanCollectionDataSource($P{myObject}.getMyList())]]></dataSourceExpression>
    </datasetRun>
    <jr:listContents height="250" width="500">
       <frame>
          <reportElement x="0" y="0" width="500" height="250" uuid="566f22c8-abbe-4709-962c-c393366555bf"/>
          <textField textAdjust="StretchHeight">
             <reportElement positionType="Float" stretchType="ContainerHeight" x="0" y="0" width="200" height="20" uuid="e8873bea-aa28-4439-b4cf-3fd40b487ae6"/>
             <textFieldExpression><![CDATA[$F{elementOne}]]></textFieldExpression>
          </textField>
          <textField textAdjust="StretchHeight">
             <reportElement positionType="Float" stretchType="ContainerHeight" x="0" y="0" width="310" height="20" uuid="fb38a2e3-f141-472b-9fe0-fd1b998eb611"/>
             <textFieldExpression><![CDATA[$F{elementTwo}]]></textFieldExpression>
          </textField>
       </frame>
    </jr:listContents>
</jr:list>

The printOrder is "Vertical". I've tried multiple attributes for example positionType="Float" such that it is dynamically loaded but it just doesn't work. I tried to put it in a subreport and in bands but then the sublist is the problem because the subreport iterates for each element once in the sublist and not once for all elements (Hence there are too many elements displayed).

How can I place the elements in the list vertically on top of each other dynamically?

Using JasperReports Version 6.20.

I have two textfields that are elements in a list that I want to iterate on. One textfield should be placed under the other. But when I try to do it, they overlap each other in the report. I can't use the simple y value, because I actually want a sublist in between that grows dynamically. For simplicity sake I only show the two textfields in the xml code.

Here is the example:

<jr:list xmlns:jr="http://jasperreports.sourcefe/jasperreports/components" xsi:schemaLocation="http://jasperreports.sourcefe/jasperreports/components http://jasperreports.sourcefe/xsd/components.xsd" printOrder="Vertical">
    <datasetRun subDataset="TableGroup" uuid="28256056-95ed-4ce9-80ee-47a10ede48f1">
       <datasetParameter name="myObject">
          <datasetParameterExpression><![CDATA[$P{myObject}]]></datasetParameterExpression>
       </datasetParameter>
       <dataSourceExpression><![CDATA[new net.sf.jasperreports.engine.data.JRBeanCollectionDataSource($P{myObject}.getMyList())]]></dataSourceExpression>
    </datasetRun>
    <jr:listContents height="250" width="500">
       <frame>
          <reportElement x="0" y="0" width="500" height="250" uuid="566f22c8-abbe-4709-962c-c393366555bf"/>
          <textField textAdjust="StretchHeight">
             <reportElement positionType="Float" stretchType="ContainerHeight" x="0" y="0" width="200" height="20" uuid="e8873bea-aa28-4439-b4cf-3fd40b487ae6"/>
             <textFieldExpression><![CDATA[$F{elementOne}]]></textFieldExpression>
          </textField>
          <textField textAdjust="StretchHeight">
             <reportElement positionType="Float" stretchType="ContainerHeight" x="0" y="0" width="310" height="20" uuid="fb38a2e3-f141-472b-9fe0-fd1b998eb611"/>
             <textFieldExpression><![CDATA[$F{elementTwo}]]></textFieldExpression>
          </textField>
       </frame>
    </jr:listContents>
</jr:list>

The printOrder is "Vertical". I've tried multiple attributes for example positionType="Float" such that it is dynamically loaded but it just doesn't work. I tried to put it in a subreport and in bands but then the sublist is the problem because the subreport iterates for each element once in the sublist and not once for all elements (Hence there are too many elements displayed).

How can I place the elements in the list vertically on top of each other dynamically?

Share Improve this question edited Jan 30 at 8:29 OhJohnny asked Jan 29 at 20:46 OhJohnnyOhJohnny 3513 silver badges13 bronze badges
Add a comment  | 

1 Answer 1

Reset to default 0

The key to align items in a list vertically to use bands. Since the bands are not placeable in a jr:list I needed to create a subreport. Putting the block in listContents in a subReport resolves the problem.

与本文相关的文章

发布评论

评论列表(0)

  1. 暂无评论