JSBaseSQLFoundset
Overview
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.
Features
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
.
Extends
Properties Summarized
Returns true if this foundset is in multiselect mode and false if it's in single-select mode.
Methods Summarized
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.
The datasource this foundset is build on
Get the index of a record object inside a foundset
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.
Get the size of present cached row identifiers (primary keys)
void
void
Set the current record index.
void
Set the selected records indexes.
void
void
void
Properties Detailed
multiSelect
Returns true if this foundset is in multiselect mode and false if it's in single-select mode.
Type Boolean true if this foundset is in multiselect mode and false if it's in single-select mode.
Methods Detailed
dispose()
Returns: Boolean
duplicateFoundSet()
Returns: JSFoundSet
forEach(callback)
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
Function 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 Object the return value of the callback
Sample
forEach(callback, thisObject)
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
Function 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.
Object thisObject What the this object should be in the callback function (default it is the foundset)
Returns: Object Object the return value of the callback
Sample
getCurrentSort()
Returns: String
getDataSource()
The datasource this foundset is build on
Returns: String the datasource
getName()
Returns: String
getRecordByPk(pk)
Parameters
Array pk ;
Returns: JSBaseSQLRecord
getRecordIndex(record)
Get the index of a record object inside a foundset
Parameters
JSRecord record the records object
Returns: Number the index or -1 if not present (anymore)
getSQL()
Returns the internal SQL of the JSFoundset. Optionally, the foundset and table filter params can be excluded in the sql (includeFilters=false).
Returns: String String representing the sql of the JSFoundset.
Sample
getSQL(includeFilters)
Returns the internal SQL of the JSFoundset. Optionally, the foundset and table filter params can be excluded in the sql (includeFilters=false).
Parameters
Boolean includeFilters include the foundset and table filters [default true].
Returns: String String representing the sql of the JSFoundset.
Sample
getSQLParameters()
Returns the parameters for the internal SQL of the QBSelect. Table filters are on by default.
Returns: Array An Array with the sql parameter values.
Sample
getSQLParameters(includeFilters)
Returns the parameters for the internal SQL of the QBSelect. Table filters are on by default.
Parameters
Boolean includeFilters include the foundset and table filters [default true].
Returns: Array An Array with the sql parameter values.
Sample
getSelectedIndex()
Get the current record index of the foundset.
Returns: Number int current index (1-based)
Sample
getSelectedIndexes()
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.
Returns: Array Array current indexes (1-based)
Sample
getSelectedRecords()
Returns: Array
getSize()
Get the size of present cached row identifiers (primary keys)
Returns: Number the number of rows which can be received via getRecord
loadAllRecords()
Returns: Boolean
revertEditedRecords()
Returns: void
save()
Returns: Boolean
setSelectedIndex(index)
Set the current record index.
Parameters
Number index index to set (1-based)
Returns: void
Sample
setSelectedIndexes(indexes)
Set the selected records indexes.
Parameters
Array indexes An array with indexes to set.
Returns: void
Sample
sort(sortString)
Parameters
String sortString ;
Returns: void
sort(sortString, defer)
Parameters
Returns: void
sort(recordComparisonFunction)
Parameters
Function recordComparisonFunction ;
Returns: void
Last updated