...
Code Block |
---|
for(var i = 1; i <= foundset.getSize(); i++){ foundset.setSelectedIndex(i); // operate on the selected record } |
Note |
See also the JSFoundset's setSelectedIndex method.
...
Code Block |
---|
for(var i = 1; i <= foundset.getSize(); i++){ var rec = foundset.getRecord(i); // does not affect the selected index } |
See also the JSFoundset's getRecord method.
...
Code Block |
---|
var ids = databaseManager.getFoundSetDataProviderAsArray(foundset,'order_id'); for(i in ids){ var id = ids[i]; } |
See also the JSFoundset's getFoundSetDataProviderAsArray method.
Sometimes there is more than one user working on the same foundset, possibly inserting or deleting records. When iterating on a foundset, it needs to be ensured that the loop neither skips nor processes twice any record due to the foundset modifications occurred from other clients. Thus, in such cases, a secure iterator is needed to perform the iteration on the foundset.
The forEach
method does exactly that, iterating over all the records of a foundset and calling the callback method given as parameter for each one of them.
Example This is an example of how to use the forEach method for iterating over a foundset.
Code Block |
---|
foundset.loadAllRecords();
foundset.forEach(
/**
* @param {JSRecord} record
* @param recordIndex
* @param {JSFoundset} fs
*/
function(record, recordIndex, fs) {
application.output("record processed: " + record + ", record index: " + recordIndex);
}
); |
See also the JSFoundset's forEach method.
Foundsets are often constrained or filtered by a Relation. In this situation, the foundset is said to be a Related Foundset and its default SQL query will include in its Where Clause, the parameters by which to constrain the foundset.
...