Collection
A class which encapsulates a keyed, filterable, sortable collection of objects. Entries may not be atomic data types such as string or number.
The entries are keyed by their id which is determined by interrogating the idProperty.
To filter a Collection, add a CollectionFilter using the addFilter method. A Filter config object may be specified here which will be promoted to a CollectionFilter instance.
To sort a Collection, add a CollectionSorter using the addSorter method. A Sorter config object may be specified here which will be promoted to a CollectionSorter instance.
Useful configs and functions
| Config / Function | Description |
|---|---|
| idProperty | Property name used as the item key |
| add | Add items to the collection |
| remove | Remove items from the collection |
| get | Get an item by its id |
| addFilter | Add a filter to the collection |
| addSorter | Add a sorter to the collection |
See also
- CollectionFilter - Filter applied to collection items
- CollectionSorter - Sorter applied to collection items
- Store - Data store built on top of Collection
Configs
Configs are options you supply in a configuration object when creating an instance of this class-
Automatically apply filters on item add.
-
Specify the name of the property of added objects which provides the lookup key
Has a corresponding runtime idProperty property.
Properties
Properties are getters/setters or publicly accessible variables on this class-
The set of values added to this Collection since the last sort or replaceValues operation.
-
The set of all values of this Collection regardless of filters applied.
-
The number of items in this collection. Note that this honours filtering. See totalCount;
-
A filter function which encapsulates the Filters for this Collection.
-
The set of filtered values of this Collection (those matching the current filters).
-
The Collection of Filters for this Collection.
-
The property name used to extract item
ids from added objects.Has a corresponding idProperty config.
-
A flag which is
trueif this Collection has active filters. -
A flag which is
trueif this Collection has active sorters. -
A sorter function which encapsulates the Sorters for this Collection.
-
The number of items in this collection regardless of filtering.
Functions
Functions are methods available for calling on the class-
clear( )
Clears this collection.