Jump to content
Changes to the Jaspersoft community edition download ×

How do I design a report with two layouts?


gantzm

Recommended Posts

Assuming I have the following data available:

 

 

Code:
Type,Color,Price
1,Red,200
1,Blue,250
1,Green,300
1,Grey,150
[Pattern continues with different colors and prices]
2,Yellow,990
2,White,875
2,Orange,1000
2,Black,950
[Pattern continues with different colors and prices]

 

How would I go about designing a report that would do the following:

 

Use one format (Title, Page Header, Detail, Etc) to print pages with items of Type 1.

 

Use a different format (Title, Page Header, Detail, Etc) to print pages with items of Type 2.

 

Have all report pages numbered in a continous manner using a "Page # of #" format.

 

[/ol]

 

To clarify, all the type "1" items would come first, followed by all the type "2" items.

 

 

Would it be possible to do this with sub reports? Or can I possibly execute two reports as a set somehow? I'm not forced to accept the data in a continous stream as presented above. If a solution requires two queries that will not be an issue.

 

 

Thanks very much,

Michael.

Link to comment
Share on other sites

  • Replies 2
  • Created
  • Last Reply

Top Posters In This Topic

Popular Days

Top Posters In This Topic

perhaps you can define two different styles; there you can insert some condition, i made something like that for differing colors at each group of data, and it worked fine. make a new frame, lay the fields in there for which the style should work and give that frame that style.

 

If you use IReport, you can make that visually very good (on the right side below, there is a style box...)

 

I don't know, if that also allows page breaks, i didn't need that...

 

 

(sorry for my english, i am out of training )

 

;)

Link to comment
Share on other sites

Well quite simple as I do something similiar where for example invoice positions can be of different types (free text or articles) and the layout for each type differs.

 

So make one SubReport for your Layout "1" and one SubReport for your Layout "2".

Make one MasterReport that just contains the page numbers in your wanted format "page X of Y" at the pageheader/footer.

 

put your SubReports in the detailband of the masterreport below each other and set the position-type to "float" (to not overlapp the first SubReport printout with the second SubReport)

 

 

make for your SubReport1 a PrintWhenExpression like this:

 

Code:
new Boolean($F{Type}.equals(new Integer(1))

(assuming that your field Type is of Integer.)

 

and for your other SubReport2 make a PrintWhenExpression like this:

 

Code:
[code]new Boolean($F{Type}.equals(new Integer(2))

(assuming that your field Type is of Integer.)

 

that's actually all (okay loading your reports -> but I think that is the simplest part)

Otherwise ask again!

 

regards from Germany

 

hth

C-Box

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