2020.2

Table Of Contents
once for each element that matches the selector. (See "Setting the scope of a script" on
page860.)
If a script runs once, accessing the detail data and dynamically added rows tends to be bit
complicated, especially when they are nested, since it involves looping over the results and
record objects (see "results" on page1420 and "record" on page1295).
If a script targets (something in) a row that is bound to a detail table, and runs once for each
matched element, the current element is accessible via the this object (see "this" on
page1338) and the current detail record is accessible via this.record.
The advantage of the latter approach is demonstrated in the example below.
Example: Styling a row based on a value in a detail table
Here are two scripts that have the same effect:if in a row, the value of the field Shipped is 1, it
colors the text of that row green.
The first script targets a cell in a Dynamic Table row that is bound to a detail table. The script
has its scope set to "Each matched element", so it can use this (see "this" on page1338) to
access the selected cell and this.record to access the current detail record, without
performing any loops.
Selector: table [data-script='Shipped'].
Scope: Each matched element
var field = this.record.fields['Shipped'];
if (field) {
this.text(formatter.upperCase(field));
if (field == 1)
this.parent().css('color', 'green');
}
Page 889