Wiki Markup | ||||
---|---|---|---|---|
Div | ||||
| }
||||
DO NOT EDIT THE CONTENT OF THIS PAGE DIRECTLY (EXCEPT INSIDE THE DIV BELOW WITH ID=DESCRIPTION), UNLESS YOU KNOW WHAT YOU'RE DOING.
STRUCTURE OF THE CONTENT IS VITAL IN BEING ABLE TO AUTO UPDATE THE CONTENT THROUGH THE DOC GENERATOR {div} {div:id=description}{div}\\ {table:id=|class=servoy sSummary}{colgroup}{column:width=80px|padding=0px}{column}{column}{column}{colgroup}{tr:style=height: 30px;}{th:colspan=2}Property Summary{th}{tr}{tbody}{tr}{td}[Boolean]{td}{td}[#allowCreationRelatedRecords] Flag that tells if related records can be created through this relation.{td}{tr}{tbody}{tbody}{tr}{td}[Boolean]{td}{td}[#allowParentDeleteWhenHavingRelatedRecords] Flag that tells if the parent record can be deleted while it has related records.{td}{tr}{tbody}{tbody}{tr}{td}[Boolean]{td}{td}[#deleteRelatedRecords] Flag that tells if related records should be deleted or not when a parent record is deleted.{td}{tr}{tbody}{tbody}{tr}{td}[String]{td}{td}[#foreignDataSource] Qualified name of the foreign data source.{td}{tr}{tbody}{tbody}{tr}{td}[String]{td}{td}[#initialSort] A String which specified a set of sort options for the initial sorting of data retrieved through this relation.{td}{tr}{tbody}{tbody}{tr}{td}[Number]{td}{td}[#joinType] The join type that is performed between the primary table and the foreign table.{td}{tr}{tbody}{tbody}{tr}{td}[String]{td}{td}[#name] The name of the relation.{td}{tr}{tbody}{tbody}{tr}{td}[String]{td}{td}[#primaryDataSource] Qualified name of the primary data source.{td}{tr}{tbody}{table}\\ {table:id=property|class=servoy sDetail}{colgroup}{column:width=100%|padding=0px}{column}{colgroup}{tr:style=height: 30px;}{th:colspan=1}Property Details{th}{tr}{tbody:id=allowCreationRelatedRecords}{tr:id=name}{td}h6.allowCreationRelatedRecords{td}{tr}{tr:id=ret}{td}*Returns*\\{div:class=sIndent}[Boolean]{div}{td}{tr}{tr:class=lastDetailRow}{td}{td}{tr}{tbody}{tbody:id=allowParentDeleteWhenHavingRelatedRecords}{tr:id=name}{td}h6.allowParentDeleteWhenHavingRelatedRecords{td}{tr}{tr:id=ret}{td}*Returns*\\{div:class=sIndent}[Boolean]{div}{td}{tr}{tr:class=lastDetailRow}{td}{td}{tr}{tbody}{tbody:id=deleteRelatedRecords}{tr:id=name}{td}h6.deleteRelatedRecords{td}{tr}{tr:id=ret}{td}*Returns*\\{div:class=sIndent}[Boolean]{div}{td}{tr}{tr:class=lastDetailRow}{td}{td}{tr}{tbody}{tbody:id=foreignDataSource}{tr:id=name}{td}h6.foreignDataSource{td}{tr}{tr:id=ret}{td}*Returns*\\{div:class=sIndent}[String]{div}{td}{tr}{tr:class=lastDetailRow}{td}{td}{tr}{tbody}{tbody:id=initialSort}{tr:id=name}{td}h6.initialSort{td}{tr}{tr:id=ret}{td}*Returns*\\{div:class=sIndent}[String]{div}{td}{tr}{tr:class=lastDetailRow}{td}{td}{tr}{tbody}{tbody:id=joinType}{tr:id=name}{td}h6.joinType{td}{tr}{tr:id=ret}{td}*Returns*\\{div:class=sIndent}[Number]{div}{td}{tr}{tr:class=lastDetailRow}{td}{td}{tr}{tbody}{tbody:id=name}{tr:id=name}{td}h6.name{td}{tr}{tr:id=ret}{td}*Returns*\\{div:class=sIndent}[String]{div}{td}{tr}{tr:class=lastDetailRow}{td}{td}{tr}{tbody}{tbody:id=primaryDataSource}{tr:id=name}{td}h6.primaryDataSource{td}{tr}{tr:id=ret}{td}*Returns*\\{div:class=sIndent}[String]{div}{td}{tr}{tr:class=lastDetailRow}{td}{td}{tr}{tbody}{table}. |
Div | ||||||||||||||||||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| ||||||||||||||||||||||||||||||||||||||||
RelationsBy default, relations join together two datasources, for example a CUSTOMERS (source) and a ORDERS (destination) table. Through RelationItems the nature of the link between the datasources is defined, for example to link the CUSTOMERS and ORDERS table based on the customer_id column. At runtime a relation is an object of type JSFoundSet. Relations are used in Solutions to display related data, for example using a Field , a TabPanel or a Portal or to work with related data in business logic. Special RelationsNext to the default relations that link two datasources together, there are several other types of relations, based on how the relation is setup. Global RelationsRelations that contain only RelationItems based on global variables on the source side, thus no dependency on the source table are considered global relations. Global relations can be used to get a limited FoundSet, for example all active customers, by adding a relation item that specifies that the "active" flag in the CUSTOMERS table has to be equal to a certain global variable. For example, if the CUSTOMERS table (used as destination datasource) contains a column called "is_active" of type INTEGER and a default value of 1 (indicating it is an active record), the following would create a global relation that returns a FoundSet with all active customers:
A global variable can be defined as an enumeration of constants, using the @enum annotation. See Annotating JavaScript Using JSDoc. The constants of the enumeration can be used in relations just as the common global variables are used.
Container RelationsIf the source and destination datasources are equal and the relation does not contain any RelationItems, it becomes a Container relation. A Container relation returns it originating FoundSet. A Container relation can be used to set the FoundSet of the parent form into the Form displayed in a TabPanel. SelfjoinsRelations can use the same datasource as source and destination datasource. Depending on the setup of the the RelationItems the relation can point back to the originating record or one or more different records. Relation OptionsRelations have several settings that influence the behavior of the Relation under different circumstances. Join TypesJoin types determine the behavior of sorting when there are no related records and the sort is performed on related fields. Inner join : When sorting records on related dataproviders over a relation that uses the "inner join" type, if a parent record does not have any related records, the parent record is excluded from the foundset
Record CreationAllow creation of related records : This property indicates if the relation can be used to create new related records
Record DeletionAllow parent delete when having related records : This property indicates if the parent record can be deleted if it has related records over this relation
Delete related records : This property indicates if child records should be automatically deleted when the parent record is deleted
Example 1: A simple scenario If an attempt is made to delete a customer record which has order and the orders have orderitems, when the relations are setup as described above the customer record will be deleted, all the orders related to the customer are deleted and all orderitems related to the orders of the customer will be deleted. As Relation 3 has the deleteRelatedRecords property set to false, no attempt will be made to delete the product record related to the orderitems that are to be deleted. Example 2: Implementing business logic enforcement in the data layer This setup is mostly the same as example 1, except for the additional fourth relation. This relation from the orders table to the invoices defines that the order record cannot be deleted if it has a related invoice record. In this setup, when an attempt is made to delete a customer record the delete is blocked if the customer has a related order that has a related invoice record. |
HTML Table | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
HTML Table | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|