Keep together static field and a sub-report on the same page

3

I have a report with the following structure in the detail band:

static field 1
text field

static field 2
text field

static field 3 - (Title for the sub-report)
sub-report

and somethimes (depending on the information present in the database) the static field 3
appears at the end of first page (alone) and the sub-report at the begining of the second page.
I wanted this case the "static field 3" was to the 2nd page.

I do not want the static field 3 inside of the sub-report. Please help me to find a solution to
keep "static field 3" and "sub-report" always together.

Thanks,
Carla

 

Code:
<frame>
				<reportElement positionType="Float" x="0" y="519" width="511" height="17"/>
				<frame>
					<reportElement style="caixa" x="0" y="10" width="242" height="5"/>
					<subreport isUsingCache="true">
						<reportElement positionType="Float" x="0" y="2" width="240" height="0"/>
						<dataSourceExpression><![CDATA[((net.sf.jasperreports.engine.data.JRXmlDataSource)$P{REPORT_DATA_SOURCE}).subDataSource("/rep1/qualificacao/pt/lingua_ucs")]]></dataSourceExpression>
						<subreportExpression class="java.lang.String"><![CDATA["repo:SuplDiplPag1Linguas_PT.jrxml"]]></subreportExpression>
					</subreport>
				</frame>
				<staticText>
					<reportElement x="0" y="0" width="242" height="8"/>
					<textElement>
						<font fontName="Lucida Sans" size="5" isBold="false"/>
					</textElement>
					<text><![CDATA[2.5. Languages ​​of the disciplines ]]></text>
				</staticText>
			</frame></td></tr></tbody></table>
carla_elisabete's picture
Joined: Jul 5 2011 - 3:33am
Last seen: 2 years 7 months ago

5 Answers:

-2

Hi,

Please help me, i have  a deadline in my project and i don't know what to do.

My question is the same for the folowing example. Imagine that we have a report to print in A4 vertically like this:

1. Static field 1 (is the title for the "Text field 1" but located in the top of the text)

Text field 1

2. Static field 2 (is the title for the "Text field 2" but located in the top of the text)

Text field 2

If the "Text field 1" is very big we may have the output of "Static field 1",  "Text field 1", "Static field 2" in the 1st page and "Text field 2" on the 2nd page. How can i ensure that if the "Text field 2" apears in 2nd page then "Static field 2" have to pass to the same page. In other words how can i create a "anchoring" between this two elements?

This is similar to the property "Page Protect" that exists in oracle report builder.

Best regards,

Carla

carla_elisabete
Wrote:

I have a report with the following structure in the detail band:

static field 1
text field

static field 2
text field

static field 3 - (Title for the sub-report)
sub-report

and somethimes (depending on the information present in the database) the static field 3
appears at the end of first page (alone) and the sub-report at the begining of the second page.
I wanted this case the "static field 3" was to the 2nd page.

I do not want the static field 3 inside of the sub-report. Please help me to find a solution to
keep "static field 3" and "sub-report" always together.

Thanks,
Carla

 

Code:
<frame>
				<reportElement positionType="Float" x="0" y="519" width="511" height="17"/>
				<frame>
					<reportElement style="caixa" x="0" y="10" width="242" height="5"/>
					<subreport isUsingCache="true">
						<reportElement positionType="Float" x="0" y="2" width="240" height="0"/>
						<dataSourceExpression><![CDATA[((net.sf.jasperreports.engine.data.JRXmlDataSource)$P{REPORT_DATA_SOURCE}).subDataSource("/rep1/qualificacao/pt/lingua_ucs")]]></dataSourceExpression>
						<subreportExpression class="java.lang.String"><![CDATA["repo:SuplDiplPag1Linguas_PT.jrxml"]]></subreportExpression>
					</subreport>
				</frame>
				<staticText>
					<reportElement x="0" y="0" width="242" height="8"/>
					<textElement>
						<font fontName="Lucida Sans" size="5" isBold="false"/>
					</textElement>
					<text><![CDATA[2.5. Languages ​​of the disciplines ]]></text>
				</staticText>
			</frame>
carla_elisabete's picture
Joined: Jul 5 2011 - 3:33am
Last seen: 2 years 7 months ago
-2

Not sure if this will solve your problem but what I'd do is to include the title of each subreport inside the subreport. For example, add it in Title band. 

And then, when you add the subreport in the main report check this property: 

Print In First Whole Band</b></u></p>
<p style="font-family: Verdana, Arial, Helvetica, sans-serif; line-height: 19px; "><b>Flag that determines whether the object gets printed in the first section of a new page or column that is not an overflow from a previous page or column.</b></p>
<p style="font-family: Verdana, Arial, Helvetica, sans-serif; line-height: 19px; ">I've never used it but it seems that if the entire subreport doesn't fit in one page everything will be added in the next page... </p>
<p style="font-family: Verdana, Arial, Helvetica, sans-serif; line-height: 19px; ">Hope this helps</p>
<p style="font-family: Verdana, Arial, Helvetica, sans-serif; line-height: 19px; ">Regards</p>
</p>

augarte's picture
533
Joined: Jan 27 2010 - 7:20am
Last seen: 1 month 3 days ago
-2

Hello

Thanks for your answer but as i said "I do not want the static field 3 inside of the sub-report" because i want a line around the sub-report and the title outside this line. And with this solution the title stays inside the line. See the Attachment please.

Best regards,

Carla

carla_elisabete's picture
Joined: Jul 5 2011 - 3:33am
Last seen: 2 years 7 months ago
-2

 And why don't you insert the line inside the subreport? I mean, put the Title in the tile band and then you can put the content in the detail band inside a line. Something like the attached example (in the example everything is inserted as static text, in  your case will be data retrieved from your database)

HTH

Regards

augarte's picture
533
Joined: Jan 27 2010 - 7:20am
Last seen: 1 month 3 days ago
6

If you have 2 objects (on 2 different lines) and you want to keep them on the same page (if possible), one solution would be to put the 2 objects inside a new detail band and set the property "Split Type" of the band to value "Prevent".

>>>>

Prevent : The band starts to render normally, but if the bottom of thepage is reached without finishing the band, the whole contents of the band that are already being laid out are moved to the next page. If the band does not fit on the next page, the split occurs normally, as band split prevention is effective only on first split attempt).

KRegards,

Radu

popadrianradu's picture
Joined: Jan 16 2013 - 8:45am
Last seen: 7 years 6 months ago
Feedback
randomness