InetSoft Reporting Software: Report Sections

A report section is a container of other elements. In most cases, you add script to the individual elements within the Section, rather than to the Section element itself. However, Section scripts also have some special behaviors, which are discussed below.

Accessing Data

When you bind a Section to a data source (i.e., to generate a pseudo-table), each band of the Section is repeated multiple times, corresponding to the number of rows returned by the query. For example, the Content band of the Section is repeated once for each detail record returned by the query.

If you place a script on a component within a repeating band, this script is re-executed for every band repetition. This has the effect of wrapping the script in an implicit “for” loop. Within the script, you can reference the values of elements in the same band:

• value – the value (in current band iteration) of the element to which the script is attached. Use auto-complete to enter the correct syn­tax.

• field['column_name'] or field.column_name – the value (in current band iteration) of the element in the specified field.

You can also refer to an element in the band by its Element ID (e.g., “Text1.text”) to obtain the current value. To obtain the row number corresponding to the current band iteration, use the sectionRow property.

Setting Visual Properties

If you place a script on a component within a repeating band, this script is re-executed for every band repetition. This has the effect of wrapping the script in an implicit “for” loop. You can take advantage of this repetition to compactly and effectively add visual style to the entire Section.

To access the visual properties of current band, use the 'band' object.

In this example, you will modify the Section content band when the query fields meet certain conditions. Follow the steps below:

#1 Ranking: Read how InetSoft was rated #1 for user adoption in G2's user survey-based index Read More

1. Create a new report, and add a Section element. Bind the Section to the 'Order details' query.

2. Select any Text element in the Content band of the Section. Right-click the element, and select 'Script' from the context menu. This opens the Script Editor for the Text element.

3. Add a script that hides the current band if the value of the 'Price' field is less than 100.

if(field['Price'] < 100) {
   band.visible = false;
 } else {
   band.visible = true;
 } 

4. Add an additional script that colors the band red if the value of the 'Quantity' field is less than or equal to 2.

if(field['Quantity'] <= 2) {
  band.background = [255,0,0];
} else {
  band.background = [255,255,255];
}
 Previous: Creating a Chart Using API Functions