I. Overview
1. Video learning
For online video learning, please see: Master-sub report.
Note: If there is any discrepancy between the document and the video, please refer to the document.
2. Application scenarios
Single-table main and sub-reports generally have more than two data sets, namely the data set of the main table and the data set of the sub-table. In terms of presentation, the main table is generally required to be displayed in a free format, and the sub-tables are displayed in a list format, which is one-to-many. relationship, there may be multiple subreports at the same time.
The single-form master-sub-report is more convenient to operate, and data can be filled in. For details, please refer to: Master-Sub Data Entry Report .
II. Examples
The data in this report is displayed in two areas: order information and order details. These two tables display order related data, that is, they are all for the same object "order", but they display different detailed order data. We call "order information" and "order details" sub reports, and the report made up of "order information" and "order details" is called the main report (this report is the main report).
1. Data preparation
Create a new dataset ds1, write the SQL query statement select * from orders
Create a new dataset ds2, write the SQL query statement select * from ordersdetail
2. Report design
Design the report as shown:
Select cells B4, D4, and under cell attributes > style, set the date to the format of month, year and day.
Select cells B7,D7, and set to number.
Select cell D12 and insert formula =B12*C12 to calculate the sales volume
3. Linkage setting
Select cell A12 and add data filtering conditions to establish the relationship between ds1 and ds2.
Select and double-click cell A12, select filter. Add a common condition to the cell to bind the "order ID" field of DS2 and the "order ID" field of DS1 to realize the association between the two datasets.
4. Pagination setting
In order to display the "order information table" and "order details table" corresponding to each expanded order ID by page, it is necessary to set the page after line.
Select cell A1, select cell attributes > other > pagination in the right property panel, and check paginate before row.
5. Effect preview
1) PC
Save the report, clickPagination Preview, the effect is as shown below:
2) Mobile terminal
For the way to view the report on the mobile terminal, please refer to the Mobile terminal preview of the report .
Both App and HTML5 are supported, and the effect is shown in the following figure:
III. Template download
Completed template, please refer to %fr_HOME%\webapps\webroot\WEB-INF\reportlets\doc-EN\ReportApplication\BasicApplication\MasterSubReport.cpt
Click download template: