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 reports in the same catalog: one contains a customer report tab which has a banded object inside and displays information of customer ID, country, city and phone, and the other contains an order report tab which contains a crosstab showing information of customer ID, product name and quantity. Now, you want to insert the order report tab as subreport into the customer report tab, and set up a link between them, so that when the end users views the customer report tab, a subreport will be built for each customer based on the order report tab, showing order records for only the specified customer.
To achieve this, take the following steps:
Fields(Primary) | OP | Fields(Subreport) |
---|---|---|
Customers_Customer ID | = | CUSTOMERS_CUSTOMERS ID |
Note: When creating sublinks, you need to avoid link loop. For example, if you set the links between the primary report A and subreport B (report A -> report B), you cannot set the link back to report A (report A -> report B -> report A).