JSFoundSet
Overview
JSFoundSet is the data model for various UI components or forms that link directly (both ways) to a datasource (db table, view, in-mem...).
It eases the read-from-db/datasource and write-to-db/datasource, editing data, data input validations and so on. It's API supports common tasks like sorting, query based loading, working through relations etc. It will automatically handle loading of data in batches from the datasource and supports lazy loading/partial loading in the UI as well (if the UI components themselves (lists / tables / trees etc.) support that).
Properties Summarized
Type | Name | Summary |
---|---|---|
Get all dataproviders of the foundset. | ||
Get or set the multiSelect flag of the foundset. |
Methods Summarized
Type | Name | Summary |
---|---|---|
Add a filter parameter that is permanent per user session to limit a specified foundset of records. | ||
Add a filter parameter that is permanent per user session to limit a specified foundset of records. | ||
Add a filter parameter that is permanent per user session to limit a specified foundset of records. | ||
Add a filter parameter that is permanent per user session to limit a specified foundset of records. | ||
void | Clear the foundset. | |
Create a new record on top of the foundset and change selection to it. | ||
Create a new record in the foundset. | ||
Create a new record in the foundset. | ||
Create a new record in the foundset and change selection to it at specified index. | ||
Create a new record in the foundset. | ||
Create a table filter that can be applied to the foundset. | ||
Delete all records in foundset, resulting in empty foundset. | ||
Delete currently selected record(s). | ||
Delete record from foundset. | ||
Delete record with the given index. | ||
Dispose a foundset from memory when foundset is no longer needed. | ||
Get a duplicate of the foundset. | ||
Duplicate current record, change selection to new record, place on top. | ||
Duplicate selected record, change selection to new record. | ||
Duplicate selected record. | ||
Duplicate record at index in the foundset, change selection to new record, place on top. | ||
Duplicate record at index in the foundset, change selection to new record. | ||
Duplicate record at index in the foundset. | ||
Duplicate record at index in the foundset, change selection to new record. | ||
Duplicate record at index in the foundset. | ||
Set the foundset in find mode. | ||
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. | ||
Get the current sort columns. | ||
Get a value based on a dataprovider name. | ||
Get the datasource used. | ||
Get the list of previously defined foundset filters. | ||
Get a previously defined foundset filter, using its given name. | ||
Get foundset name. | ||
Returns a JSDataSet with the PKs omitted on this foundset If no PKs have been omitted, an empty JSDataSet will be returned | ||
Gets the parent records when called on a related foundset. | ||
Get the query that the foundset is currently using (as a clone; modifying this QBSelect will not automatically change the foundset). | ||
Get the query that the foundset is currently using (as a clone; modifying this QBSelect will not automatically change the foundset). | ||
Get the record object at the given index. | ||
Get the loaded record based on its primary key values. | ||
Get the record index. | ||
Gets the relation name (null if not a related 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 selected record. | ||
Get the selected records. | ||
Get the number of records in this foundset. | ||
Check wether the foundset has any conditions from a previous find action. | ||
void | Invert the foundset against all rows of the current table. | |
Returns a boolean if this foundset is in a cleared state (has the clear condition that is added by a clear() call) | ||
Check if the foundset was disposed. | ||
Check if this foundset is in find mode. | ||
Loads all accessible records from the datasource into the foundset. | ||
Loads the records that are currently omitted as a foundset. | ||
Reloads all last (related) records again, if, for example, after search in tabpanel. | ||
Copies foundset data from another foundset. | ||
Loads a primary key dataset, will remove related sort. | ||
Loads records into form foundset based on a query builder object (also known as 'Form by query'). | ||
Loads a single record by primary key, will remove related sort. | ||
Loads a single record by primary key, will remove related sort. | ||
Loads records into form foundset based on a query (also known as 'Form by query'). | ||
Loads records into form foundset based on a query (also known as 'Form by query'). | ||
Create a new record on top of the foundset and change selection to it. | ||
Create a new record in the foundset and change selection to it. | ||
Create a new record in the foundset. | ||
Create a new record in the foundset and change selection to it. | ||
Create a new record in the foundset. | ||
Omit selected record(s) (add it to omit records list), to be shown with loadOmittedRecords. | ||
Omit record sent as parameter (add it to omit records list), to be shown with loadOmittedRecords. | ||
Omit record under the given index (add it to omit records list), to be shown with loadOmittedRecords. | ||
void | Reloads all last records again with the filters applied. | |
void | Perform a relookup for the currently selected records Lookups are defined in the dataprovider (columns) auto-enter setting and are normally performed over a relation upon record creation. | |
void | Perform a relookup for the record under the given index Lookups are defined in the dataprovider (columns) auto-enter setting and are normally performed over a relation upon record creation. | |
Remove a named foundset filter. | ||
Start the database search and use the results, returns the number of records, make sure you did "find" function first. | ||
Start the database search and use the results, returns the number of records, make sure you did "find" function first. | ||
Start the database search and use the results, returns the number of records, make sure you did "find" function first. | ||
Select the record based on pk data. | ||
void | Set a value based on a dataprovider name. | |
Set multiple foundset filters at the same time. | ||
void | Set the current record index. | |
void | Set the selected records indexes. | |
void | Sorts the foundset based on the given sort string. | |
void | Sorts the foundset based on the given sort string. | |
void | Sorts the foundset based on the given record comparator function. | |
Create a new unrelated foundset that is a copy of the current foundset. |
Properties Detailed
alldataproviders
Get all dataproviders of the foundset.
Type Array
Sample
multiSelect
Get or set the multiSelect flag of the foundset.
Type Boolean
Sample
Methods Detailed
addFoundSetFilterParam(query)
Add a filter parameter that is permanent per user session to limit a specified foundset of records.
Filters on tables touched in the query will not be applied to the query filter. For example, when a table filter exists on the order_details table, a query filter with a join from orders to order_details will be applied to the foundset, but the filter condition on the orders_details table will not be included.
Use clear(), reloadWithFilters(), loadRecords() or loadAllRecords() to make the filter effective. Multiple filters can be added to the same dataprovider, they will all be applied.
Parameters
QBSelect query condition to filter on.
Returns: Boolean true if adding the filter succeeded, false otherwise.
Sample
addFoundSetFilterParam(query, name)
Add a filter parameter that is permanent per user session to limit a specified foundset of records.
Filters on tables touched in the query will not be applied to the query filter. For example, when a table filter exists on the order_details table, a query filter with a join from orders to order_details will be applied to the foundset, but the filter condition on the orders_details table will not be included.
Use clear(), reloadWithFilters(), loadRecords() or loadAllRecords() to make the filter effective. The filter is removed again using removeFoundSetFilterParam(name).
The table of the query has to be the same as the foundset table.
Parameters
Returns: Boolean true if adding the filter succeeded, false otherwise.
Sample
addFoundSetFilterParam(dataprovider, operator, value)
Add a filter parameter that is permanent per user session to limit a specified foundset of records. Use clear(), reloadWithFilters(), loadRecords() or loadAllRecords() to make the filter effective. Multiple filters can be added to the same dataprovider, they will all be applied.
Parameters
String dataprovider String column to filter on.
String operator String operator: =, <, >, >=, <=, !=, (NOT) LIKE, (NOT) IN, (NOT) BETWEEN and IS (NOT) NULL optionally augmented with modifiers "#" (ignore case) or "^||" (or-is-null), prefix with "sql:" to allow the value to be interpreted as a custom query.
Object value Object filter value (for in array and between an array with 2 elements)
Returns: Boolean true if adding the filter succeeded, false otherwise.
Sample
addFoundSetFilterParam(dataprovider, operator, value, name)
Add a filter parameter that is permanent per user session to limit a specified foundset of records. Use clear(), reloadWithFilters(), loadRecords() or loadAllRecords() to make the filter effective. The filter is removed again using removeFoundSetFilterParam(name).
Parameters
String dataprovider String column to filter on.
String operator String operator: =, <, >, >=, <=, !=, (NOT) LIKE, (NOT) IN, (NOT) BETWEEN and IS (NOT) NULL optionally augmented with modifiers "#" (ignore case) or "^||" (or-is-null), prefix with "sql:" to allow the value to be interpreted as a custom query.
Object value Object filter value (for in array and between an array with 2 elements)
String name String name, used to remove the filter again.
Returns: Boolean true if adding the filter succeeded, false otherwise.
Sample
clear()
Clear the foundset.
This will set a special condition in the query that makes the query not return any results.
But if new Records are added to this foundset, then those records become the query pk set. So it will then behave the same as loadRecord(pkset) of a pkset of those new records.
You can query for this state in the isCleared() call so you can call loadRecords() to remove that cleared state if needed.
Returns: void
Sample
createRecord()
Create a new record on top of the foundset and change selection to it. Returns the new record or null if record was not created.
Returns: JSRecord IJSRecord the new record
Sample
createRecord(onTop)
Create a new record in the foundset. Returns the new record or null if the record can't be made.
Parameters
Boolean onTop when true the new record is added as the topmost record.
Returns: JSRecord IJSRecord of new record.
Sample
createRecord(onTop, changeSelection)
Create a new record in the foundset. Returns the new record or null if the record can't be made.
Parameters
Boolean onTop when true the new record is added as the topmost record; when false the record is added to the end, if all records are loaded, otherwise it will be added to the top
Boolean changeSelection when true the selection is changed to the new record.
Returns: JSRecord IJSRecord of new record.
Sample
createRecord(index)
Create a new record in the foundset and change selection to it at specified index. Returns the new record or null if the record can't be made.
Parameters
Number index the new record is added at specified index (1-based).
Returns: JSRecord IJSRecord of new record.
Sample
createRecord(index, changeSelection)
Create a new record in the foundset. Returns the new record or null if the record can't be made.
Parameters
Number index the new record is added at specified index (1-based).
Boolean changeSelection when true the selection is changed to the new record.
Returns: JSRecord IJSRecord of new record.
Sample
createTableFilterParam(dataprovider, operator, value)
Create a table filter that can be applied to the foundset. Multiple filters can be applied at the same time using foundset.setTableFilters().
Parameters
String dataprovider A specified dataprovider column name.
String operator One of "=, <, >, >=, <=, !=, LIKE, or IN" optionally augmented with modifiers "#" (ignore case) or "^||" (or-is-null), prefix with "sql:" to allow the value to be interpreted as a custom query.
Object value The specified filter value.
Returns: JSTableFilter table filter or null when no filter could be created.
Sample
deleteAllRecords()
Delete all records in foundset, resulting in empty foundset.
Returns: Boolean boolean true if all records could be deleted.
Sample
deleteRecord()
Delete currently selected record(s). If the foundset is in multiselect mode, all selected records are deleted.
Returns: Boolean boolean true if all records could be deleted.
Sample
deleteRecord(record)
Delete record from foundset.
Parameters
JSRecord record The record to delete from the foundset.
Returns: Boolean boolean true if record could be deleted.
Sample