v7.3.0

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

No results

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.

  • A Sorter, or Sorter config object, or an array of these, to use to sort this Collection.

    Has a corresponding runtime sorters property.

Properties

Properties are getters/setters or publicly accessible variables on this class
    • addedValues : Object[]
      private
      READONLY

      The set of values added to this Collection since the last sort or replaceValues operation.

    • allValues : Object[]
      READONLY

      The set of all values of this Collection regardless of filters applied.

    • count : Number
      READONLY

      The number of items in this collection. Note that this honours filtering. See totalCount;

    • A filter function which encapsulates the Filters for this Collection.

    • filteredValues : Object[]
      private
      READONLY

      The set of filtered values of this Collection (those matching the current filters).

    • filters : Collection
      READONLY

      The Collection of Filters for this Collection.

    • The property name used to extract item ids from added objects.

      Has a corresponding idProperty config.

    • isFiltered : Boolean
      READONLY

      A flag which is true if this Collection has active filters.

    • isSorted : Boolean
      READONLY

      A flag which is true if this Collection has active sorters.

    • A sorter function which encapsulates the Sorters for this Collection.

    • The Collection of Sorters for this Collection.

      Has a corresponding sorters config.

    • totalCount : Number
      READONLY

      The number of items in this collection regardless of filtering.

    Functions

    Functions are methods available for calling on the class
      • clear( )

        Clears this collection.

      Events

      Events are triggered for certain actions in this class and can be listened for to react to those actions in your code

      Event handlers

      Event handlers are callbacks called as a result of certain actions in this class

      Source path

      Core/util/Collection.js

      Contents