13.07.2015 Views

iReport Ultimate Guide - Nimsoft Library

iReport Ultimate Guide - Nimsoft Library

iReport Ultimate Guide - Nimsoft Library

SHOW MORE
SHOW LESS
  • No tags were found...

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

SubreportsFigure 10-7Just a list of countriesNext, let’s start to create the report that will be used as the subreport. The subreport must have the following characteristics:• No margins (this is not mandatory, but of course we don’t need them).• No parameter to host the name of the country.• The width must be congruent with the space we want to reserve for it in the master report; let’s use the entire page widthminus the margins.• A set of textfields in the Detail band to show first and last name of each customer.1. Create a new empty report called subreport.jrxml (if you pick a different name, keep it in mind because we will use itwhen connecting the master to the subreport).2. Remove the page margins and adjust the page width (that is, an A4 page has a width of 595 pixels, subtracting 20 pixelsfor the left margin and 20 for the right one, the new page should be set to a width of 555 pixels with margins of 0).3. Add to this report a parameter that we’ll call COUNTRY.The type must be set to java.lang.String and the default value to a blank string (“”) or, if you prefer, to a countryname like “Argentina”. This default value will be overridden by whatever we specify from the master report. We areassigning it to the parameter now only because a default value in <strong>iReport</strong> (not in UR) is mandatory when usinga parameter inside a report query.4. Open the query dialog and enter the query to select the customer information based on the order’s country; it can besomething like this:select distinct shipname, shipcity from orders where shipcountry = $P{COUNTRY}157

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!