A2v10 Platform documentation
UK


Properties and Methods of the Array

Each array is extended with the following additional utility properties and methods:

Each item in the array implements the IArrayElement interface and contains some additional properties and methods.


Properties

readonly $root: IRoot

Reference to the root object of the model (IRoot).

readonly $parent: IElement

Reference to the parent of the array (IElement).

readonly $ctrl: IController

Reference to the controller object (IController).

readonly $hasSelected: boolean

Does the array have a selected item (the one with the $selected property set to true).

readonly $selectedIndex: number

The index of the selected item, or -1 if there is no selected item.

readonly $checked: IElementArray<T>

An array of checked ($checked = true) elements of the current array.

readonly $cross: { [prop: string]: string[] }

The key object for the cross data models.Returns an object with property names that match the cross fields. The values are an array of strings - cross keys.

Methods

			
		

Description

Clears the array. Removes all items.

Returns:

  • reference to the array itself..
			
		

Description

Reloads an array from the database. Makes sense only for children and “lazy” arrays.

Returns:

  • promise with the reference to the array itself.
			
		

Description

Removes the specified item from the array.

Arguments:

  • elem - item being removed.

Returns:

  • reference to the array itself.
			
		

Description

Clears the selection flag from all items of the array.

Returns:

  • reference to the array itself.
			
		

Description

Inserts an item at the end of the array. If the source is specified and is an object, then its properties are copied to the newly inserted item.

Arguments:

  • src - source to insert from. Can be a regular (non-reactive) javascript object.

Returns:

  • Inserted item.
			
		

Description

Inserts an item at the beginning of an array. If the source is specified and is an object, then its Properties are copied to the newly inserted item.

Arguments:

  • src - source to insert from. Can be a regular (non-reactive) javascript object.

Returns:

  • Inserted item.
			
		

Description

Inserts a new item into the array.

Arguments:

  • src - source. Can be a regular (non-reactive) javascript object.
  • to - place of insertion. Possible values:
    • 'start' - to the beginning of the array (equivalent of $prepend).
    • 'end' - to the end of the array (equivalent of $append).
    • 'above' - before the specified (ref) item.
    • 'below' - after the specified (ref) item.
  • ref - item relative to which the insertion will be performed for to = 'above' | 'below'.

Returns:

  • Inserted item.
			
		

Description

Copies the source into the current array.

Arguments:

  • src - source for the copying. Can be a regular (non-reactive) javascript object. Properties of the source which are not in the item are ignored.

Returns:

  • array itself.
			
		

Description

Calculates the sum for the items of an array.

Arguments:

  • fn - a callback function that should return a property of the array item to add.

Returns:

  • Calculated sum.
			
		

Description

Searches the array for the first matching item. This function differs from a regular array search in that it performs recursive tree searches for hierarchical arrays.

Arguments:

  • fn - a callback function that should return true, if the item matches the selection criteria. Function arguments:
    • this? - argument value thisArg.
    • item - array item.
    • index? - item index.
    • array? - the array to search through.
  • thisArg - this argument value for callback function.

Returns:

  • Found item.

			
		

Description

Whether the array is "lazy".

Returns:

  • true, if the array is "lazy" (with lazy loading).
			
		

Description

Resets the "lazy" array loading flag. On the next call, the array will be reloaded from the server.