Sectioning out a report is a simple, intuitive method of improving both your and your user’s experience. By dividing a report into sections, you can:
- Display grouped and aggregated data intuitively
- Implement a consistent code-once design on repetitive elements like headers and footers
- Create visual breaks in the report, allowing the user to scan and find information quickly
- Improve your coding experience by providing smaller groups of code for better focus
- Section examples:
- Headers and footers
- Two tables of data in the same printed page
Subsections—also known as “nested” or “child” sections—allow us to further break down the report, both visually and in code. Nested sections can:
- Improve your coding experience
- Hide visual noise when you’re working on a different section
- Work in smaller code chunks
- Provide additional user interactivity, such as by expanding and collapsing sections of a report
- Hide or show data depending on the user of the report
When would I use a subsection?
- Hide confidential information from certain users. In this case, you could write a script to control the section’s visibility in OnPrint event.
- Allow users to expand or collapse a table. Again, you’d simply set the Visible property.
- Format summarized data differently than other data. If you want to show a sum total, for instance, you may want it to be boldfaced and moved to the bottom of a page.
When would I not use a subsection?
If you need to ensure that an entire section displays on one sheet of printed paper, avoid subsections. “KeepTogether” often fails when too many subsections are implemented. Generally speaking, subsections are the most useful when you need to both inherit the properties of the parent section and set some additional functionality. Subsections in FlexReport
How Subsections Work in FlexReport
Every section in FlexReport can have multiple subsections added in a single step. Right-click a section and choose Add Subsection: Add a Subsection Subsections are named alphabetically.
How a Subsection Compares Its Parent Section
- Inherits the parent's properties
- Subsections do not:
- Have events
- Have a Repeat property
Use Cases for Subsections
Use Case #1: Hide sections conditionally and apply formatting.
Suppose you have a report where you calculate nationwide sales for a salesperson. Here are our requirements:
- Group by country and the salesperson’s name.
- Calculate if the person has exceeded the goal by comparing with a certain amount. Display a message only if the salesperson has exceeded their goal.
- Visually differentiate Detail sections.
Mockup of finished report We could accomplish some of these requirements by placing all our fields in a single section. Something like this: Formatting without subsections The problem is, if you place them all in a single section and hide only the goal message conditionally, the goal message is technically still there—just not visible. Which means we’ll end up with an empty space where the message should be. In addition, the table’s header row would have the same background color: Report without subsections Let’s walk through the steps to fulfill our requirements.
- Create three subsections.
- Employee_GroupHeader (Salesperson name)
- Employee_GroupHeader (Exceeded sales message)
- Employee_GroupHeader (Header labels for table)
Designing the report with subsections meets the requirements
- Now we need to set the visibility on the “exceeded goals” message.
- In EmployeeGroup.Header.OnFormat event, set Visible property of subsection to true or false, based on the current condition:
Write a condition to set the section's visibility.
The message displays when the condition is true.
Use Case #2: Move a summary section to the bottom of the page.
In this report, we’re showing per-customer sales. Here are the requirements:
- Group the report by customer name.
- Display the total sales per customer.
- Display the cumulative total of all customer groups at the bottom of each page.
Move this summary to the bottom of the page. Using FlexReport, the layout of the report can be created like this: Create a subsection for the summary data. One way to meet the requirements is to write a script suppressing the “Total Sales: Sum(OrderValue)” value in the GroupFooter OnPrint event. Then we’d add the field to the PageFooter section, which can be tricky and time-consuming. Let’s try it with subsections instead.
- Right-click GroupFooter0 and choose “Add subsection.” GroupFooter0 gets divided into “GroupFooter0 / ” and “GroupFooter0/ “ subsections.
- Select “Total Sales: Sum(OrderValue)” from “GroupFooter0/ ” and place it in “GroupFooter0/ “ subsection.
- Select “Group Footer0/” subsection and set PrintAtPageBottom to True.
- That’s it! Preview the report.The cumulative “Total Sales: Sum(OrderValue)” is printed at bottom of the Page.
Watch the video:
We’d love to hear some of your subsections use cases. Share in comments! Read more about FlexReport >>