sean.1.barry Posted December 15, 2020 Share Posted December 15, 2020 I have a Jasper report that is iterating over a list of data returned by a query and displaying the data in tabular format. Depending on the number of table rows the contents of the table might be split across two pages.Is there a way to prevent this data splitting and cause the entire table to appear on the next page if it doesn't all fit on the current page?The detail band of my report is as follows:<detail> <band height="100" splitType="Prevent"> <componentElement> <reportElement x="0" y="0" width="800" height="20" isPrintWhenDetailOverflows="true" uuid="3e389075-14ca-4f57-9d02-175fbc34a639"/> <jr:list xmlns:jr="http://jasperreports.sourceforge.net/jasperreports/components" xsi:schemaLocation="http://jasperreports.sourceforge.net/jasperreports/components http://jasperreports.sourceforge.net/xsd/components.xsd" printOrder="Vertical"> <datasetRun subDataset="output" uuid="acf7113d-1f5a-4acc-ad2c-70efb491bb4f"> <dataSourceExpression><![CDATA[new net.sf.jasperreports.engine.data.JRMapCollectionDataSource($F{output})]]></dataSourceExpression> </datasetRun> <jr:listContents height="60" width="800"> <textField> <reportElement isPrintRepeatedValues="false" x="0" y="20" width="555" height="20" uuid="156e4ef8-b8d9-4dc4-8a50-4f27e0f36a83"/> <textFieldExpression><![CDATA[$F{reference}]]></textFieldExpression> </textField> <componentElement> <reportElement x="0" y="40" width="200" height="20" uuid="3e389075-14ca-4f57-9d02-175fbc34a639"/> <jr:list printOrder="Vertical"> <datasetRun subDataset="unitDetails" uuid="acf7113d-1f5a-4acc-ad2c-70efb491bb4f"> <dataSourceExpression><![CDATA[new net.sf.jasperreports.engine.data.JRMapCollectionDataSource($F{units})]]></dataSourceExpression> </datasetRun> <jr:listContents height="40" width="800"> <textField> <reportElement x="0" y="0" width="100" height="20" uuid="ead7d8ba-12e2-4a0e-af92-66a50b34148f"/> <textFieldExpression><![CDATA[$F{businessUnit}]]></textFieldExpression> </textField> <componentElement> <reportElement x="0" y="20" width="800" height="20" uuid="85e29233-08b3-4717-b260-82c9e4a003c5"/> <jr:table> <datasetRun subDataset="codeDetails" uuid="1f5dfa57-f961-4574-b663-8637b2aa6f6e"> <dataSourceExpression><![CDATA[new net.sf.jasperreports.engine.data.JRMapCollectionDataSource($F{codes})]]></dataSourceExpression> </datasetRun> <jr:column width="100" uuid="f832562c-1459-44a4-89df-fe5feadfe7ee"> <jr:detailCell height="20"> <textField> <reportElement x="0" y="0" width="100" height="20" uuid="e2ce6b92-bf8a-45f8-936a-af99b2ced4e7"/> <textElement textAlignment="Left"/> <textFieldExpression><![CDATA[$F{code}]]></textFieldExpression> </textField> </jr:detailCell> </jr:column> <jr:column width="150" uuid="b8c51d7d-f4d2-47c9-90a8-2449dff2a9f9"> <jr:columnHeader height="20"> <staticText> <reportElement x="0" y="0" width="150" height="20" uuid="2fc57842-d68d-4398-a0df-4eddd74316fd"/> <textElement textAlignment="Right"/> <text><![CDATA[Total]]></text> </staticText> </jr:columnHeader> <jr:detailCell height="20"> <textField> <reportElement x="0" y="0" width="150" height="20" uuid="b2953321-ce5d-4e5f-94e3-8b48b49bbf90"/> <textElement textAlignment="Right"/> <textFieldExpression><![CDATA[$F{total}]]></textFieldExpression> </textField> </jr:detailCell> </jr:column> <jr:column width="150" uuid="f8e255a7-951d-43ad-962b-f4ee32efaa80"> <jr:columnHeader height="20"> <staticText> <reportElement x="0" y="0" width="150" height="20" uuid="69deede1-0fbc-4fd0-b430-4f0f3cacdc4f"/> <textElement textAlignment="Right"/> <text><![CDATA[Approved]]></text> </staticText> </jr:columnHeader> <jr:detailCell height="20"> <textField> <reportElement x="0" y="0" width="150" height="20" uuid="200263e0-f9fb-4626-8cee-3eb838d51add"/> <textElement textAlignment="Right"/> <textFieldExpression><![CDATA[$F{approved}]]></textFieldExpression> </textField> </jr:detailCell> </jr:column> <jr:column width="150" uuid="b4d8feb1-4134-4302-bad1-902685238d3e"> <jr:columnHeader height="20"> <staticText> <reportElement x="0" y="0" width="150" height="20" uuid="096581a7-beec-43bc-a17e-ce96c4384838"/> <textElement textAlignment="Right"/> <text><![CDATA[Rejected]]></text> </staticText> </jr:columnHeader> <jr:detailCell height="20"> <textField> <reportElement x="0" y="0" width="150" height="20" uuid="3c5d019f-c4af-479b-b180-d52a6606d4e0"/> <textElement textAlignment="Right"/> <textFieldExpression><![CDATA[$F{rejected}]]></textFieldExpression> </textField> </jr:detailCell> </jr:column> </jr:table> </componentElement> </jr:listContents> </jr:list> </componentElement> </jr:listContents> </jr:list> </componentElement> </band> </detail>The report output looks like the following where the bottom of the page has the table headings but not the contents because the contents don't fit. 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