Jump to content
We've recently updated our Privacy Statement, available here ×

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


carla_elisabete

Recommended Posts

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>
Link to comment
Share on other sites

  • Replies 5
  • Created
  • Last Reply

Top Posters In This Topic

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:
Link to comment
Share on other sites

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

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.

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... 

Hope this helps

Regards

Link to comment
Share on other sites

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

Link to comment
Share on other sites

 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

Link to comment
Share on other sites

  • 7 months later...

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

Link to comment
Share on other sites

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 account

Sign in

Already have an account? Sign in here.

Sign In Now

×
×
  • Create New...