2020.2

Table Of Contents
// Create the number of rows based on the records in the detail
table
// We start at 1 so the boilerplate row is used too and there is no
need to delete that row
for(var r = 1; r < record.tables['detail'].length; r++) {
results.parent().append(results.clone());
}
// Iterate over the rows and populate them with the data from the
accompanying data row
query("#table_2 > tbody > tr").each(function(i) {
this.find('@ItemNumber@').text( record.tables['detail'][i].fields
["ItemNumber"]);
this.find('@ItemOrdered@').text( record.tables['detail'][i].fields
["ItemOrdered"]);
this.find('@ItemTotal@').text( record.tables['detail'][i].fields
["ItemTotal"]);
this.find('@ItemDesc@').text( record.tables['detail'][i].fields
["ItemDesc"]);
this.find('@nr@').text(i);
});
The following script clones and populates a boilerplate row. Once completed you will need to
hide the boilerplate row.
closest()
This function gets the first parent element that matches a selector, by testing the element itself
and traversing up through its ancestors in the DOM tree. (In HTML, a parent is an element that
contains another element.)
The function can be used for:
l The elements that match the selector of a script (see "results" on page929).
l One element that matches the selector of a script that runs for "Each matched element"
(see "this" on page849 and "Setting the scope of a script" on page387).
l The elements returned by a query in the template (see "query()" on page804).
To get a child element or all child elements, use children() (see "children()" on page864).
Page 866