This article discusses the basic steps for creating a Master - Detail report.
1. First, create a relation between data sources. If the relation will not be created and/or the relation properties of the Detail data source cannot be filled, then for the Master entry, all Detail entries will be output.
1. Insert two DataBands on a page of a report template.
Figure 1: Template with two data bands
1. Edit DataBand1 and DataBand2:
· Align them by height
· Change values of required properties. For example:
· Set the PrintIfDetailEmpty property of the DataBand1 that is the Master component in the Master-Detail report to true, if it is necessary that all Master entries be printed in any case, even if Detail entries are not present.
· Also, set the CanShrink property of the DataBand2 that is the Detail component in the Master-Detail report to true, if it is necessary to shrink this band
· Change the background colour of the Data
1. Define data sources for DataBands, define the Master component. In this tutorial, the Master component is the DataBand1. This means that in the Data Setup window of the lower DataBand2, the DataBand1 will be specified as the Master component in the Master Component tab
2. Enter the Data Relation property of the DataBand, which is the Detail components. In this case, it is DataBand2.
3. Put text components with expressions on DataBands. Where the expression is a reference to the data field. For example:
· Put a text component with the expression {InvProductGroup.Description} on the DataBand1.
· Put a text component with {InvProduct.Id} and {InvProduct.Description} expressions in the DataBand2.
4. Edit Text and TextBox components:
· Drag and drop the text component in DataBands;
· Change parameters of the text font: size, type, colour;
· Align the text component by width and height;
· Change the background of the text component;
· Align text in the text component;
· Change the value of properties of the text component. For example:
· Set the Word Wrap property to true, if you need a text to be wrapped
· Enable Borders for the text component, if required.
· Change the border colour.
The picture below shows the master-detail report template.
Figure 2 : Master-Detail Report Template
1. Click the [Preview] button or invoke the Viewer, by pressing F5 or clicking the Preview menu item. After rendering all references to data fields, they will be changed on the data form specified fields. Data will be output in consecutive order from the database that was defined for this report. The amount of copies of the DataBand in the rendered report will be the same as the amount of data rows in the database. The picture below shows a sample of the Master-Detail report:
Figure 3 : Master-Detail Report
1. Go back to the report template.
1. If needed, add other bands to the report template, for example, HeaderBand and FooterBand
1. Edit these bands:
· Align them by height;
· Change values of properties, if required;
· Change the background of bands;
· Enable Borders, if required;
· Set the border colour.
1. Put text components with expressions in these bands. The expression in the text component is a header in the HeaderBand, and a footer in the FooterBand.
2. Edit text and text components:
· Drag and drop the text components in the band
· Change font options: size, type, colour
· Align text components by height and width
· Change the background of the text components
· Align text in the text components
· Change values of text component properties, if required
· Enable Borders of the text components, if required
· Set the border colour.
The picture below shows a Master-Detail report template with HeaderBand and FooterBand:
Figure 4 : Report Template with Header and Footer
1. Click the [Preview] button or invoke the Viewer, by pressing F5 or clicking the Preview menu item. After rendering all references to data fields, they will be changed on the data form specified fields. Data will be output in consecutive order from the database that was defined for this report. The amount of copies of the DataBand in the rendered report will be the same as the amount of data rows in the database. The picture below shows a sample of the Master-Detail report with header and footer.
Figure 5 : Master-Detail report with Header and Footer and updated formatting