Page History
...
When a user types a value into a text field (which is bound to a specific column of the database table) and clicks out, the Servoy Application Server issues a SQL update command to the database to modify the selected record. The resulting change is also broadcast|display/DOCS/Data+Broadcasting||||||||||||||||||||||||||||||||||||||\ to all connected clients.
...
The fundamental unit of data binding in both the GUI and the API is the Servoy Foundset|display/DOCS/Foundsets+Concepts||||||||||||||||||||||||||||||||||||||\ object.
...
The Foundset maintains a Selected Index, a cursor with which to step through the records. If the selected index equals or exceeds the size of the Foundset, the Foundset will automatically issue another query to load the next batch of primary key data. Thus the Foundset loads record data and grows dynamically with the changing Selected Index property.
...
lang | javascript |
---|---|
title | Example dynamic Foundset size |
borderStyle | solid |
. There are two methods used to get/set the foundsets selected index. They are getSelectedIndex and setSelectedIndex respectively.
Example: In the example below, note that the foundset's size changes after the selected index has changed. The foundset's cache grows dynamically
Code Block |
---|
// Foundset size grows dynamically as the Foundset is traversed foundset.getSize(); // returns 200 foundset.setSelectedIndex(200); foundset.getSize(); // returns 400 because the foundset loaded the next 200 record pks |
Iterating over a Foundset
Often, as part of some programming operation, it is necessary to iterate over part or all of a foundset. There are several approaches to iterating, each having their appropriate usage. General a Javascript for or while statement is used to control the flow of execution.
Changing the Selected Index
Perhaps the most intuitive approach is to programmatically change the foundset's selected index property.
Example: The example below iterates over the entire foundset using a for loop.
Code Block |
---|
for(var i = 1; i <= foundset.getSize(); i++){ foundset.setSelectedIndex(i); // operate on the selected record } |
Directly Accessing a Record Object
Accessing Data Provider Values as an Array
Related Foundsets
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.
...