JSBaseFoundset
Overview
JSBaseFoundSet
provides a unified interface for working with foundsets, exposing shared functionalities for regular and view foundsets. It supports key operations such as iteration, selection, and data source retrieval. The multi-select mode allows multiple records to be handled simultaneously. This abstraction ensures consistency across various foundset types.
Features
JSBaseFoundSet
allows iteration over records with the forEach
method, which handles dynamic loading while respecting Servoy’s lazy-loading mechanism. Callback functions can interact with records while accommodating changes like inserts and deletions. Exceptions ensure stability when the foundset is modified during iteration.
The class provides methods to retrieve details about the data source and selected records. Methods like getDataSource
return the underlying data source, while getSelectedIndex
and getSelectedIndexes
provide details about currently selected records. The size of the cached row identifiers can be retrieved using getSize
.
Selection Management
JSBaseFoundSet
includes methods for managing record selection. Developers can set or retrieve the currently selected record index with setSelectedIndex
and getSelectedIndex
. For multi-select scenarios, setSelectedIndexes
and getSelectedIndexes
enable handling multiple selected records.
For more information, refer to the FoundSet documentation.
Properties Summarized
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.
Properties Detailed
multiSelect
Type Boolean true if the foundset is in multi-select mode; false otherwise.
Methods Detailed
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
getDataSource()
Returns: String the data source of the foundset as a string.
getName()
Returns: String the name of the foundset.
getRecordIndex(record)
Parameters
JSRecord record ;
Returns: Number the 0-based index of the given record in the foundset.
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 an array of currently selected records in the foundset.
getSize()
Returns: Number the number of records in the foundset.
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
Last updated
Was this helpful?