JSBaseSQLFoundset
Last updated
Was this helpful?
Last updated
Was this helpful?
JSBaseSQLFoundSet
is the foundational class for SQL-based foundsets, including JSFoundSet
and ViewFoundSet
. It provides functionality to handle SQL-driven data operations within Servoy environments. This class extends JSFoundSet
, enabling inheritance of its capabilities and adding specific methods for SQL-based operations.
The JSBaseSQLFoundSet
supports multiselect mode, allowing multiple records to be selected simultaneously, making it suitable for batch operations. It includes mechanisms to iterate over records using the forEach
method, which dynamically loads records while accounting for concurrent inserts and deletes, ensuring data consistency during operations.
Developers can retrieve the internal SQL used by the foundset through the getSQL
method, along with parameters via getSQLParameters
. Options are available to include or exclude table filters from the returned SQL and parameters. Additional capabilities include sorting records with sort
, duplicating the foundset using duplicateFoundSet
, saving changes with save
, and reverting unsaved edits using revertEditedRecords
.
Iterates over the records of a foundset taking into account inserts and deletes that may happen at the same time.
Iterates over the records of a foundset taking into account inserts and deletes that may happen at the same time.
Returns the internal SQL of the JSFoundset.
Returns the internal SQL of the JSFoundset.
Returns the parameters for the internal SQL of the QBSelect.
Returns the parameters for the internal SQL of the QBSelect.
Get the current record index of the foundset.
Get the indexes of the selected records.
void
void
Set the current record index.
void
Set the selected records indexes.
void
void
void
Iterates over the records of a foundset taking into account inserts and deletes that may happen at the same time. It will dynamically load all records in the foundset (using Servoy lazy loading mechanism). If callback function returns a non null value the traversal will be stopped and that value is returned. If no value is returned all records of the foundset will be traversed. Foundset modifications( like sort, omit...) cannot be performed in the callback function. If foundset is modified an exception will be thrown. This exception will also happen if a refresh happens because of a rollback call for records on this datasource when iterating. When an exception is thrown from the callback function, the iteration over the foundset will be stopped.
Parameters
Sample
Iterates over the records of a foundset taking into account inserts and deletes that may happen at the same time. It will dynamically load all records in the foundset (using Servoy lazy loading mechanism). If callback function returns a non null value the traversal will be stopped and that value is returned. If no value is returned all records of the foundset will be traversed. Foundset modifications( like sort, omit...) cannot be performed in the callback function. If foundset is modified an exception will be thrown. This exception will also happen if a refresh happens because of a rollback call for records on this datasource when iterating. When an exception is thrown from the callback function, the iteration over the foundset will be stopped.
Parameters
Sample
Parameters
Parameters
Returns the internal SQL of the JSFoundset. Optionally, the foundset and table filter params can be excluded in the sql (includeFilters=false).
Sample
Returns the internal SQL of the JSFoundset. Optionally, the foundset and table filter params can be excluded in the sql (includeFilters=false).
Parameters
Sample
Returns the parameters for the internal SQL of the QBSelect. Table filters are on by default.
Sample
Returns the parameters for the internal SQL of the QBSelect. Table filters are on by default.
Parameters
Sample
Get the current record index of the foundset.
Sample
Get the indexes of the selected records. When the foundset is in multiSelect mode (see property multiSelect), a selection can consist of more than one index.
Sample
Returns: void
Set the current record index.
Parameters
Returns: void
Sample
Set the selected records indexes.
Parameters
Returns: void
Sample
Parameters
Returns: void
Parameters
Returns: void
Parameters
Returns: void
Type true if the foundset is in multi-select mode; false otherwise.
Returns: true if the foundset was successfully disposed; false otherwise.
Returns: a new instance of the duplicated foundset.
callback The callback function to be called for each loaded record in the foundset. Can receive three parameters: the record to be processed, the index of the record in the foundset, and the foundset that is traversed.
Returns: Object the return value of the callback
callback The callback function to be called for each loaded record in the foundset. Can receive three parameters: the record to be processed, the index of the record in the foundset, and the foundset that is traversed.
thisObject What the this object should be in the callback function (default it is the foundset)
Returns: Object the return value of the callback
Returns: the current sort order as a string.
Returns: the data source of the foundset as a string.
Returns: the name of the foundset.
pk ;
Returns: The record corresponding to the given primary key(s), or null if no matching record is found.
record ;
Returns: the 0-based index of the given record in the foundset.
Returns: String representing the sql of the JSFoundset.
includeFilters include the foundset and table filters [default true].
Returns: String representing the sql of the JSFoundset.
Returns: An Array with the sql parameter values.
includeFilters include the foundset and table filters [default true].
Returns: An Array with the sql parameter values.
Returns: int current index (1-based)
Returns: Array current indexes (1-based)
Returns: an array of currently selected records in the foundset.
Returns: the number of records in the foundset.
Returns: true if all records are successfully loaded; false otherwise.
Returns: true if the changes are successfully saved; false otherwise.
index index to set (1-based)
indexes An array with indexes to set.
sortString ;
sortString ;
defer ;
recordComparisonFunction ;