Child pages
  • JSRelation

Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.
Divcache
HTML Table
id
classservoy sSummary
Colgroup Tag
Col
width80px
Col
Table Head (thead)
Table Row (tr)
styleheight: 30px;
Table Head (th)
colspan2
Constants Summary
Table Row (tr)
Table Cell (td)
Number
Table Cell (td)FULL_JOIN
styleindexdisplay:none

DO NOT EDIT THE CONTENT OF THIS PAGE DIRECTLY (EXCEPT INSIDE THE DIV BELOW WITH ID=DESCRIPTION), UNLESS YOU KNOW WHAT YOU'RE DOING.
THE STRUCTURE OF THE CONTENT IS VITAL IN BEING ABLE TO AUTO UPDATE THE CONTENT THROUGH THE DOC GENERATOR.

Div
iddescription
For more information see Relations
true
refresh100d
showRefreshtrue
iddoc
titleRefresh page
showDatetrue
retryEnable

servoy sReturnTypes2100%height: 30px;2Supported ClientssWordListSmartClientsWordListWebClientsWordListNGClient

servoy sSummary12%30%58%height: 30px;3Constants SummaryConstant for the joinType of a Query Builder join.

Table Row (tr)
Table Cell (td)
Number
Table Cell (td)INNER_JOIN
Table Cell (td)LEFT_OUTER_JOIN
Constant for the joinType of a JSRelation. Table Row (tr)
Table Cell (td)
Number
RIGHT_OUTER_JOIN
Constant for the joinType of a JSRelation. Table Row (tr)
Table Cell (td)
Number
Table Cell (td)Constant for the joinType of a Query Builder join.

HTML Table

idclassservoy sSummary

Colgroup Tag
Col
width80px
Col
Table Head (thead) Table Row (tr)style
Table Cell (td)
Boolean
Table Cell (td)allowCreationRelatedRecords
servoy sSummary12%30%58%height: 30px;
Table Head (th)
colspan2
Property Summary
Table Row (tr)3Property SummaryFlag that tells if related records can be created through this relation. Table Row (tr)
Table Cell (td)
Boolean
Table Cell (td)allowParentDeleteWhenHavingRelatedRecords
Flag that tells if the parent record can be deleted while it has related records. Table Row (tr)
Table Cell (td)
Boolean
Table Cell (td)deleteRelatedRecords
Table Row (tr)
Table Cell (td)
String
Table Cell (td)foreignDataSource
Flag that tells if related records should be deleted or not when a parent record is deleted.Qualified name of the foreign data source. Table Row (tr)
Table Cell (td)
String
Table Cell (td)initialSort
A String which specified a set of sort options for the initial sorting of data
retrieved through this relation. Table Row (tr)
Table Cell (td)
Number
Table Cell (td)joinType
Table Row (tr)
Table Cell (td)
String
Table Cell (td)name
The join type that is performed between the primary table and the foreign table.
Table Cell (td)
String
Table Cell (td)primaryDataSource
The name of the relation. Table Row (tr)Qualified name of the primary data source.

HTML Table

idclassservoy sSummaryid

Colgroup Tag
Col
width80px
Col
Table Head (thead) Table Row (tr)style Table Row (tr)
Table Cell (td)
JSRelationItem[]
Table Cell (td)getRelationItems()
servoy sSummary12%30%58%height: 30px;
Table Head (th)
colspan2
Method Summary
3Methods SummaryReturns an array of JSRelationItem objects representing the relation criteria defined for this relation. Table Row (tr)
Table Cell (td)
UUID
Table Cell (td)getUUID()
newRelationItem(dataprovider, operator, foreinColumnName)
Returns the UUID of the relation object Table Row (tr)
Table Cell (td)
JSRelationItem
Table Cell (td)Creates a new relation item for this relation. Table Row (tr) Table Cell (td)void Table Cell (td)removeRelationItem(primaryDataProviderID, operator, foreignColumnName)
Removes the desired relation item from the specified relation.

HTML Table

constantclass Colgroup Tag Colcolspanservoy sDetail2width100%

Col
Table Head (thead) Table Row (tr)styleheight:30px; Table Head (th)colspan2Constants Details Table Body (tbody)ididFULL_JOIN Table Row (tr)nametdid

FULL_JOIN

Table Row (tr)des Table Cell (td) DivclasssIndentConstant for the joinType of a Query Builder join. Table Row (tr)idtdret

Returns

divsIndentclients

classtd

Supported Clients

sIndent
Number Table Row (tr)
idsam
SmartClient,WebClient,NGClientsam

Sample

Div
classsIndent
Code Block
languagejavascript
/** @type {QBSelect<db:/example_data/orders>} */
	var query = databaseManager.createSelect('db:/example_data/orders')
 /** @type {QBJoin<db:/example_data/order_details>} */
	var join = query.joins.add('db:/example_data/order_details', JSRelation.RIGHT_OUTER_JOIN, 'odetail')
	join.on.add(join.columns.orderid.eq(query.columns.orderid))
Table Row (tr)
classlastDetailRow
Table Cell (td)
 
Table Body (tbody)
idINNER_JOIN
Table Row (tr)
idname
Table Cell (td)

INNER_JOIN

Table Row (tr)
iddes
Table Cell (td) Div
classsIndent
Table Row (tr)idsIdentjavascriptlastDetailRow&nbsp;INNER_JOINname

INNER_JOIN

dessIndentConstant for the joinType of a JSRelation. It is also used in solutionModel.newRelation(...) and in the QueryBuilder.
tdret

Returns

divsIndentclients

classtd

Supported Clients

sIndent
Number Table Row (tr)
idsam
Table Body (tbody)idSmartClient,WebClient,NGClientsam

Sample

Div
classsIndent
Code Block
languagejavascript
var relation = solutionModel.newRelation('parentToChild', 'db:/example_data/parent_table', 'db:/example_data/child_table', JSRelation.INNER_JOIN);
relation.joinType = JSRelation.LEFT_OUTER_JOIN;

 /** @type {QBSelect<db:/example_data/orders>} */
	var query = databaseManager.createSelect('db:/example_data/orders')
 /** @type {QBJoin<db:/example_data/order_details>} */
	var join = query.joins.add('db:/example_data/order_details', JSRelation.INNER_JOIN, 'odetail')
	join.on.add(join.columns.orderid.eq(query.columns.orderid))
Table Row (tr)
classlastDetailRow
Table Cell (td)
 
sIdentjavascriptlastDetailRow&nbsp;LEFT_OUTER_JOIN Table Row (tr)idtdname

LEFT_OUTER_JOIN

Table Row (tr)idclass

des Table Cell (td) DivsIndent Table Row (tr)idConstant for the joinType of a JSRelation. It is also used in solutionModel.newRelation(...) and in the QueryBuilder.tdret

Returns

divsIndentclients

classtd

Supported Clients

sIndent
Number Table Row (tr)
idsam
Table Body (tbody)idSmartClient,WebClient,NGClientsam

Sample

Div
classsIndent
Code Block
languagejavascript
var relation = solutionModel.newRelation('parentToChild', 'db:/example_data/parent_table', 'db:/example_data/child_table', JSRelation.INNER_JOIN);
relation.joinType = JSRelation.LEFT_OUTER_JOIN;

 /** @type {QBSelect<db:/example_data/orders>} */
	var query = databaseManager.createSelect('db:/example_data/orders')
 /** @type {QBJoin<db:/example_data/order_details>} */
	var join = query.joins.add('db:/example_data/order_details', JSRelation.INNER_JOIN, 'odetail')
	join.on.add(join.columns.orderid.eq(query.columns.orderid))
Table Row (tr)
classlastDetailRow
Table Cell (td)
 
sIdentjavascriptlastDetailRow&nbsp;RIGHT_OUTER_JOIN Table Row (tr)idname

Table Cell (td)

RIGHT_OUTER_JOIN

tr

idclassdes Table Cell (td) DivsIndentConstant for the joinType of a Query Builder join. Table Row (tr)idret

Table Cell (td)

Returns

divsIndentclients

classtd

Supported Clients

sIndent
Number Table Row (tr)
idsam
Colgroup Tag
Col
colspan2
width100%
Col
Table Head (thead)
Table Row (tr)
styleheight: 30px;
Table Head (th)
colspan2
Property Details
Table Body (tbody)
idallowCreationRelatedRecords
Table Row (tr)
idname
Table Cell (td)

allowCreationRelatedRecords

Table Row (tr)
iddes
Table Cell (td) Div
classsIndent
SmartClient,WebClient,NGClientsam

Sample

Div
classsIndent
Code Block
languagejavascript
/** @type {QBSelect<db:/example_data/orders>} */
	var query = databaseManager.createSelect('db:/example_data/orders')
 /** @type {QBJoin<db:/example_data/order_details>} */
	var join = query.joins.add('db:/example_data/order_details', JSRelation.RIGHT_OUTER_JOIN, 'odetail')
	join.on.add(join.columns.orderid.eq(query.columns.orderid))
Table Row (tr)
classlastDetailRow
Table Cell (td)
 
HTML Table
idproperty
classservoy sDetail
sIdentjavascriptlastDetailRow&nbsp;

propertyservoy sDetail2100%height:30px2Property DetailsallowCreationRelatedRecordsname

allowCreationRelatedRecords

dessIndentFlag that tells if related records can be created through this relation.
The default value of this flag is "false". Table Row (tr)idret

Table Cell (td)

Returns

divsIndentclients

classtd

Supported Clients

sIndent
Boolean Table Row (tr)
idsam
Table Row (tr)
classlastDetailRow
Table Cell (td)
 
Table Body (tbody)
idallowParentDeleteWhenHavingRelatedRecords
Table Row (tr)
idname
Table Cell (td)

allowParentDeleteWhenHavingRelatedRecords

Table Row (tr)
iddes
Table Cell (td) Div
classsIndent
SmartClient,WebClient,NGClientsam

Sample

Div
classsIndent
Code Block
languagejavascript
var relation = solutionModel.newRelation('parentToChild', 'db:/example_data/parent_table', 'db:/example_data/child_table', JSRelation.INNER_JOIN);
relation.allowCreationRelatedRecords = true;
sIdentjavascriptlastDetailRow&nbsp;allowParentDeleteWhenHavingRelatedRecordsname

allowParentDeleteWhenHavingRelatedRecords

dessIndentFlag that tells if the parent record can be deleted while it has related records.
The default value of this flag is "true". Table Row (tr)idtdret

Returns

divsIndentclients

classid

Supported Clients

sIndent
Boolean Table Row (tr)SmartClient,WebClient,NGClientsam

Table Cell (td)

Table Row (tr)
classlastDetailRow
Table Cell (td)
 
Table Body (tbody)
iddeleteRelatedRecords
Table Row (tr)
idname
Table Cell (td)

deleteRelatedRecords

Table Row (tr)
iddes
Table Cell (td) Div
classsIndent

Sample

Div
classsIndent
Code Block
languagejavascript
var relation = solutionModel.newRelation('parentToChild', 'db:/example_data/parent_table', 'db:/example_data/child_table', JSRelation.INNER_JOIN);
relation.allowParentDeleteWhenHavingRelatedRecords = false;
sIdentjavascriptlastDetailRow&nbsp;deleteRelatedRecordsname

deleteRelatedRecords

dessIndentFlag that tells if related records should be deleted or not when a parent record is deleted.
The default value of this flag is "false". Table Row (tr)idtdret

Returns

divsIndentclients

classtd

Supported Clients

sIndent
Boolean Table Row (tr)
idsam
Table Row (tr)
classlastDetailRow
Table Cell (td)
 
Table Body (tbody)
idforeignDataSource
Table Row (tr)
idname
Table Cell (td)

foreignDataSource

Table Row (tr)
iddes
Table Cell (td) Div
classsIndent
SmartClient,WebClient,NGClientsam

Sample

Div
classsIndent
Code Block
languagejavascript
var relation = solutionModel.newRelation('parentToChild', 'db:/example_data/parent_table', 'db:/example_data/child_table', JSRelation.INNER_JOIN);
relation.deleteRelatedRecords = true;
sIdentjavascriptlastDetailRow&nbsp;foreignDataSourcename

foreignDataSource

dessIndentQualified name of the foreign data source. Contains both the name of the foreign

Table Row (tr)id server and the name of the foreign table.tdret

Returns

divsIndentclients

classtd

Supported Clients

sIndent
String Table Row (tr)
idsam
Table Row (tr)
classlastDetailRow
Table Cell (td)
 
Table Body (tbody)
idinitialSort
Table Row (tr)
idname
Table Cell (td)

initialSort

Table Row (tr)
iddes
Table Cell (td) Div
classsIndent
SmartClient,WebClient,NGClientsam

Sample

Div
classsIndent
Code Block
languagejavascript
var relation = solutionModel.newRelation('parentToChild', 'db:/example_data/parent_table', 'db:/example_data/child_table', JSRelation.INNER_JOIN);
relation.primaryDataSource = 'db:/user_data/another_parent_table';
relation.foreignDataSource = 'db:/user_data/another_child_table';
sIdentjavascriptlastDetailRow&nbsp;initialSortname

initialSort

dessIndentA String which specified a set of sort options for the initial sorting of data

retrieved through this relation. Table Row (tr)id Has the form "column_name asc, another_column_name desc, ...".tdret

Returns

divsIndentclients

classtd

Supported Clients

sIndent
String Table Row (tr)
idsam
Table Row (tr)
classlastDetailRow
Table Cell (td)
 
Table Body (tbody)
idjoinType
Table Row (tr)
idname
Table Cell (td)

joinType

Table Row (tr)
iddes
Table Cell (td) Div
classsIndent
SmartClient,WebClient,NGClientsam

Sample

Div
classsIndent
Code Block
languagejavascript
var relation = solutionModel.newRelation('parentToChild', 'db:/example_data/parent_table', 'db:/example_data/child_table', JSRelation.INNER_JOIN);
relation.initialSort = 'another_child_table_text asc';
sIdentjavascriptlastDetailRow&nbsp;joinTypename

joinType

dessIndentThe join type that is performed between the primary table and the foreign table.

Table Row (tr)id Can be "inner join" or "left outer join".tdret

Returns

divsIndentclients

classtd

Supported Clients

sIndent
Number Table Row (tr)
idsam
Table Row (tr)
classlastDetailRow
Table Cell (td)
 
Table Body (tbody)
idname
Table Row (tr)
idname
Table Cell (td)

name

Table Row (tr)
iddes
Table Cell (td) Div
classsIndent
SmartClient,WebClient,NGClientsam

Sample

Div
classsIndent
Code Block
languagejavascript
var relation = solutionModel.newRelation('parentToChild', 'db:/example_data/parent_table', 'db:/example_data/child_table', JSRelation.INNER_JOIN);
relation.joinType = JSRelation.LEFT_OUTER_JOIN;

 /** @type {QBSelect<db:/example_data/orders>} */
	var query = databaseManager.createSelect('db:/example_data/orders')
 /** @type {QBJoin<db:/example_data/order_details>} */
	var join = query.joins.add('db:/example_data/order_details', JSRelation.INNER_JOIN, 'odetail')
	join.on.add(join.columns.orderid.eq(query.columns.orderid))
sIdentjavascriptlastDetailRow&nbsp;namename

name

dessIndentThe name of the relation.
Table Row (tr)idret

Table Cell (td)

Returns

divsIndentclients

classtd

Supported Clients

sIndent
String Table Row (tr)
idsam
Table Row (tr)
classlastDetailRow
Table Cell (td)
 
Table Body (tbody)
idprimaryDataSource
Table Row (tr)
idname
Table Cell (td)

primaryDataSource

Table Row (tr)
iddes
Table Cell (td) Div
classsIndent
SmartClient,WebClient,NGClientsam

Sample

Div
classsIndent
Code Block
languagejavascript
var relation = solutionModel.newRelation('parentToChild', 'db:/example_data/parent_table', 'db:/example_data/child_table', JSRelation.INNER_JOIN);
relation.name = 'anotherName';
var firstTab = tabs.newTab('firstTab', 'Child Form', childForm, relation);
firstTab.relationName = relation.name;
sIdentjavascriptlastDetailRow&nbsp;primaryDataSourcename

primaryDataSource

dessIndentQualified name of the primary data source. Contains both the name of the primary server

Table Row (tr)id and the name of the primary table.ret

Table Cell (td)

Returns

divsIndentclients

classtd

Supported Clients

sIndent
String Table Row (tr)
idsam
Colgroup Tag
Col
colspan2
width100%
Col
Table Head (thead)
Table Row (tr)
styleheight: 30px;
Table Head (th)
colspan2
Method Details
Table Body (tbody)
idgetRelationItems
Table Row (tr)
idname
Table Cell (td)

getRelationItems

Table Row (tr)
idsig
Table Cell (td)
Span
stylemargin-right: 5px;
JSRelationItem[]
Span
stylefont-weight: bold;
getRelationItems
Span
()
Table Row (tr)
iddes
Table Cell (td) Div
classsIndent
SmartClient,WebClient,NGClientsam

Sample

Div
classsIndent
Code Block
languagejavascript
var relation = solutionModel.newRelation('parentToChild', 'db:/example_data/parent_table', 'db:/example_data/child_table', JSRelation.INNER_JOIN);
relation.primaryDataSource = 'db:/user_data/another_parent_table';
relation.foreignDataSource = 'db:/user_data/another_child_table';
Table Row (tr)
classlastDetailRow
Table Cell (td)
 
HTML Table
idfunction
classservoy sDetail
sIdentjavascriptlastDetailRow&nbsp;

functionservoy sDetail2100%height:30px2Methods DetailsgetRelationItemsname

getRelationItems()

dessIndentReturns an array of JSRelationItem objects representing the relation criteria defined for this relation.
Table Row (tr)idret

Table Cell (td)

Returns

div
Table Row (tr)
idname
Table Cell (td)

getUUID

Table Row (tr)
idsig
Table Cell (td)
Span
stylemargin-right: 5px;
UUID
Span
stylefont-weight: bold;
getUUID
Span
()
Table Row (tr)
iddes
Table Cell (td) Div
classsIndent
sIndentclients

classsIndent
JSRelationItem[] - An array of JSRelationItem instances representing the relation criteria of this relation.
Table Row (tr)
idsam
Table Cell (td)

Sample

Div
classsIndent
Code Block
languagejavascript
var criteria = relation.getRelationItems();
for (var i=0; i<criteria.length; i++)
{
	var item = criteria[i];
	application.output('relation item no. ' + i);
	application.output('primary column: ' + item.primaryDataProviderID);
	application.output('operator: ' + item.operator);
	application.output('foreign column: ' + item.foreignColumnName);
}
Table Row (tr)
classlastDetailRow
Table Cell (td)
 
Table Body (tbody)
idgetUUID

Supported Clients

sIndentSmartClient,WebClient,NGClient
sam

Sample

sIdentjavascript
lastDetailRow&nbsp;
getUUIDname

getUUID()

dessIndentReturns the UUID of the relation object
Table Row (tr)idtdret

Returns

divsIndentclients

classtd

Supported Clients

sIndent
UUID Table Row (tr)
idsam
Table Row (tr)
classlastDetailRow
Table Cell (td)
 
Table Body (tbody)
idnewRelationItem-String_String_String
Table Row (tr)
idname
Table Cell (td)

newRelationItem

Table Row (tr)
idsig
Table Cell (td)
Span
stylemargin-right: 5px;
JSRelationItem
Span
stylefont-weight: bold;
newRelationItem
SpanSmartClient,WebClient,NGClientsam

Sample

Div
classsIndent
Code Block
languagejavascript
var relation = solutionModel.newRelation('parentToChild', 'db:/example_data/parent_table', 'db:/example_data/child_table', JSRelation.INNER_JOIN);
application.output(relation.getUUID().toString())
sIdentjavascriptlastDetailRow&nbsp;newRelationItemname

newRelationItem(dataprovider, operator, foreinColumnName)

tr

id Divclassdes Table Cell (td)sIndentCreates a new relation item for this relation. The primary dataprovider, the foreign data provider
Table Row (tr)id and one relation operators (like '=' '!=' '>' '<') must be provided.tdprs

Parameters

Divclass

sIndent{String} dataprovider - The name of the primary dataprovider.
{String} operator - The operator used to relate the primary and the foreign dataproviders.
{String} foreinColumnName - Table Row (tr)idThe name of the foreign dataprovider.ret

Table Cell (td)

Returns

div
Span
stylemargin-right: 5px;
void
Span
stylefont-weight: bold;
removeRelationItem
SpansIndentclients

classsIndent
JSRelationItem - A JSRelationItem instance representing the newly added relation item.
Table Row (tr)
idsam
Table Cell (td)

Sample

Div
classsIndent
Code Block
languagejavascript
var relation = solutionModel.newRelation('parentToChild', 'db:/example_data/parent_table', 'db:/example_data/child_table', JSRelation.INNER_JOIN);
relation.newRelationItem('another_parent_table_id', '=', 'another_child_table_parent_id');
// for literals use a prefix
relation.newRelationItem(JSRelationItem.LITERAL_PREFIX + "'hello'",'=', 'mytextfield');
Table Row (tr)
classlastDetailRow
Table Cell (td)
 
Table Body (tbody)
idremoveRelationItem-String_String_String
Table Row (tr)
idname
Table Cell (td)

removeRelationItem

Table Row (tr)
idsig
Table Cell (td)id

Supported Clients

sIndentSmartClient,WebClient,NGClient
sam

Sample

sIdentjavascript
lastDetailRow&nbsp;
removeRelationItemname

removeRelationItem(primaryDataProviderID, operator, foreignColumnName)

Table Row (tr) Table Cell (td) DivclassdessIndentRemoves the desired relation item from the specified relation. Table Row (tr)idtdprs

Parameters

Divclass

sIndent{String} primaryDataProviderID - the primary data provider (column) name
{String} operator - the operator
{String} foreignColumnName - Table Row (tr)idthe foreign column nametdret

Returns

divsIndentclients

classid

Supported Clients

sIndent
void Table Row (tr)SmartClient,WebClient,NGClientsam

Table Cell (td) Table Row (tr)

classlastDetailRow
Table Cell (td) 

Sample

Div
classsIndent
Code Block
languagejavascript
var relation = solutionModel.newRelation('myRelation', 'db:/myServer/parentTable', 'db:/myServer/childTable', JSRelation.INNER_JOIN);
relation.newRelationItem('someColumn1', '=', 'someColumn2');
relation.newRelationItem('anotherColumn', '=', 'someOtherColumn');
relation.removeRelationItem('someColumn1', '=', 'someColumn2');
var criteria = relation.getRelationItems();
for (var i = 0; i < criteria.length; i++) {
	var item = criteria[i];
	application.output('primary column: ' + item.primaryDataProviderID);
	application.output('operator: ' + item.operator);
	application.output('foreign column: ' + item.foreignColumnName);
}
sIdentjavascriptlastDetailRow&nbsp;