3.9.2 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.

Walkthrough

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

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];

}

 

See Also

band, for more information about the band object, and its properties.

<< 3.9.1 Accessing Data © 1996-2013 InetSoft Technology Corporation (v11.4) 3.10 Report Beans >>