A sublink is a way to connect the primary report and the subreport. When you define a sublink, JReport will match the records with equal relationships within the subreport and the primary report. You can apply one or more links to make the subreport and the primary report interlinked.
The following example explains the use of sublinks in detail.
Assume that you have two report sets in the same catalog: one contains a customer report which has a banded object inside and displays information of customer ID, country, city and phone, and the other contains an order report which contains a crosstab showing information of customer ID, product name and quantity. Now, you want to insert the order report as subreport into the customer report, and set up a link between them, so that when the end users views the customer report, a subreport will be built for each customer based on the order report, showing order records for only the specified customer.
To achieve this, take the following steps:
on the Insert toolbar.
A box is then attached to the mouse pointer to indicate it is ready to place the subreport.
| Fields(Primary) | OP | Fields(Subreport) |
|---|---|---|
| Customers_Customer ID | = | CUSTOMERS_CUSTOMERS ID |
When you preview the customer report, crosstab is generated for each customer based on the customer ID. See the result.
Notes: