MenuFoundSet
Overview
MenuFoundSet
enables a menu structure to function as a datasource, allowing menu items to be treated as records within the Servoy Developer environment. This provides access to menu properties as dataproviders, which are read-only, and supports hierarchical relationships, such as parent-child structures based on parentid
. These capabilities allow components like DBTreeView to work seamlessly with menu records and enable complex menu representations with FormComponents.
Example Usage
For further details on setting up and working with datasources, see Datasource Setup.
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.
Returns the datasource (menu:name) for this MenuFoundSet.
Get foundset name (menu name).
Get the MenuItemRecord object at the given index.
Get the index of a record object inside a foundset
Get the record index.
Get the current record index of the foundset.
Get the indexes of the selected records.
Get the selected records.
Get the number of records in this menu foundset.
void
Set the current record index.
void
Set the selected records indexes.
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
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 the datasource (menu:name) for this MenuFoundSet.
Returns: String
Sample
getName()
Get foundset name (menu name).
Returns: String name.
Sample
getRecord(index)
Get the MenuItemRecord object at the given index. Argument "index" is 1 based (so first record is 1).
Parameters
Number index record index (1 based).
Returns: JSRecord MenuItemRecord record.
Sample
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)
getRecordIndex(record)
Get the record index. Will return -1 if the record can't be found.
Parameters
JSRecord record MenuItemRecord
Returns: Number int index.
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
getSelectedRecord()
Returns: JSRecord
getSelectedRecords()
Get the selected records. When the menu foundset is in multiSelect mode (see property multiSelect), selection can be a more than 1 record.
Returns: Array Array current records.
Sample
getSize()
Get the number of records in this menu foundset. All records are loaded when foundset is initialized.
Returns: Number int current size.
Sample
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