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.
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 syntax.
• 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: