Properties

new EditableChildCollectionSync(parent[, eventHandlers])

Creates a new synchronous editable child collection instance.

The name of the model type available as: <instance>.constructor.modelType, returns 'EditableChildCollectionSync'.

Valid parent model types are:

 * EditableRootModelSync
 * EditableChildModelSync

Parameters

Name Type Optional Description

parent

object

 

The parent business object.

eventHandlers

bo.shared.EventHandlerList

Yes

The event handlers of the instance.

Extends
CollectionBase
Throws

Argument error: The parent object must be an EditableRootModelSync or EditableChildModelSync instance.

Properties

read-only
$modelName  string

The name of the model.

read-only
count  number

The count of the child objects in the collection.

Methods

at(index) → EditableChildModelSync

Gets a collection item at a specific position.

Parameter

Name Type Optional Description

index

number

 

The index of the required item in the collection.

Returns

EditableChildModelSync The required collection item.

protected
checkRules()

Executes validation on all items of the collection.

This method is called by the parent object.

create(index) → EditableChildModelSync

Creates a new item and adds it to the collection at the specified index.

Parameter

Name Type Optional Description

index

number

 

The index of the new item.

Returns

EditableChildModelSync The newly created business object.

every(callback) → boolean

Tests whether all items in the collection pass the test implemented by the provided function.

Parameter

Name Type Optional Description

callback

external.cbCollectionItem

 

Function to test for each collection item.

Returns

boolean True when callback returns truthy value for each item, otherwise false.

protected
fetch([data])

Initializes the items in the collection with data retrieved from the repository.

This method is called by the parent object.

Parameter

Name Type Optional Description

data

Array of object

Yes

The data to load into the business object collection.

filter(callback) → Array of EditableChildModelSync

Creates a new array with all collection items that pass the test implemented by the provided function.

Parameter

Name Type Optional Description

callback

external.cbCollectionItem

 

Function to test for each collection item.

Returns

Array of EditableChildModelSync The new array of collection items.

forEach(callback)

Executes a provided function once per collection item.

Parameter

Name Type Optional Description

callback

external.cbCollectionItem

 

Function that produces an item of the new collection.

fromCto(data)

Rebuilds the business object collection from a plain object array sent by the client.
This method is usually called by the parent object.

Parameter

Name Type Optional Description

data

Array of object

 

The array of client transfer objects.

protected
getBrokenRules([namespace]) → Array of bo.rules.BrokenRulesOutput

Gets the broken rules of all items of the collection.

This method is called by the parent object.

Parameter

Name Type Optional Description

namespace

string

Yes

The namespace of the message keys when messages are localizable.

Returns

Array of bo.rules.BrokenRulesOutput The broken rules of the collection.

protected
isValid() → boolean

Indicates whether all items of the collection are valid.

This method is called by the parent object.

Returns

boolean True when the business collection is valid, otherwise false.

map(callback) → Array of any type

Creates a new array with the results of calling a provided function on every item in this collection.

Parameter

Name Type Optional Description

callback

external.cbCollectionItem

 

Function to test for each collection item.

Returns

Array of any type The new array of callback results.

remove()

Marks all items in the collection to be deleted from the repository on next save.

protected
save(connection)

Saves the changes of the business object collection to the repository.

This method is called by the parent object.

Parameter

Name Type Optional Description

connection

object

 

The connection data.

some(callback) → boolean

Tests whether some item in the collection pass the test implemented by the provided function.

Parameter

Name Type Optional Description

callback

external.cbCollectionItem

 

Function to test for each collection item.

Returns

boolean True when callback returns truthy value for some item, otherwise false.

sort([fnCompare]) → EditableChildCollectionSync

Sorts the items of the collection in place and returns the collection.

Parameter

Name Type Optional Description

fnCompare

external.cbCompare

Yes

Function that defines the sort order. If omitted, the collection is sorted according to each character's Unicode code point value, according to the string conversion of each item.

Returns

EditableChildCollectionSync The sorted collection.

toCto() → Array of object

Transforms the business object collection to a plain object array to send to the client.
This method is usually called by the parent object.

Returns

Array of object The client transfer object.