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.
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.
Clears the array. Removes all items.
Reloads an array from the database. Makes sense only for children and “lazy” arrays.
Removes the specified item from the array.
elem
- item being removed.
Clears the selection flag from all items of the array.
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.
src
- source to insert from. Can be a regular (non-reactive) javascript object.
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.
src
- source to insert from. Can be a regular (non-reactive) javascript object.
Inserts a new item into the array.
src
- source. Can be a regular (non-reactive) javascript object.
to
- place of insertion. Possible values:
$prepend
).$append
).ref
) item.ref
) item.ref
- item relative to which the insertion will be performed for to = 'above' | 'below'
.Copies the source into the current array.
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.
Calculates the sum for the items of an array.
fn
- a callback function that should return a property of the array item to add.
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.
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.
Resets the "lazy" array loading flag. On the next call, the array will be reloaded from the server.