Class: SelectionModel

SelectionModel()

SelectionModel provides a simple in-memory store for data that fires events when a item is selected (added) or deselected (removed)

Constructor

new SelectionModel()

Source:

Members

_fireEvents

Properties:
Name Type Description
Flag Boolean that control the firing of action events: onSelect, onDeselect, onClear
Source:

clearAsDeselect

Properties:
Name Type Description
Flag Boolean that determines how to clear: True: Deselect is called on every item, firing onDeselect for each and firing onClear at the end False: Collection is immediately wiped and only onClear is fired
Source:

count

Properties:
Name Type Description
Number Number of selections
Source:

requireSelection

Properties:
Name Type Description
Flag Boolean to indicate a selection is required.
Source:

selections

Properties:
Name Type Description
Collection Object of selections where the key is the selections key
Source:

Methods

clear()

Removes all items from the store
Source:

deselect(key)

Removes an item from the store
Parameters:
Name Type Description
key String Unique identifier string that was given when the item was added
Source:

getSelectedKeys() → {Array.<String>}

Returns a list of unique identifier keys used in the selection collection
Source:
Returns:
All keys in the store
Type
Array.<String>

getSelectionCount() → {Number}

Returns the number of items in the store
Source:
Returns:
Current count of items
Type
Number

getSelections() → {Object}

Returns all items in the store
Source:
Returns:
The entire selection collection
Type
Object

isSelected(key) → {Boolean}

Determines if the given key is in the selections collection.
Parameters:
Name Type Description
key String Unique identifier string that was given when the item was added
Source:
Returns:
True if the item is in the store.
Type
Boolean

onClear(self)

Event that happens when the store is cleared
Parameters:
Name Type Description
self
Source:

onDeselect(key, data, tag, self)

Event that happens when an item is deselected/removed.
Parameters:
Name Type Description
key String Unique identifier string
data Object The item removed
tag
self
Source:

onSelect(key, data, tag, self)

Event that happens when an item is selected/added.
Parameters:
Name Type Description
key String Unique identifier string
data Object The item stored
tag
self
Source:

resumeEvents()

Enables the firing of action events: onSelect, onDeselect, onClear
Source:

select(key, data, tag)

Adds an item to the `selections` if it is not already stored.
Parameters:
Name Type Description
key String Unique identifier string
data Object The item being selected
tag
Source:

suspendEvents()

Prevents the firing of action events: onSelect, onDeselect, onClear
Source:

toggle(key, data, tag)

Adds an item to the `selections` if it is not already stored, if it is stored, then it deselects (removes) the item.
Parameters:
Name Type Description
key String Unique identifier string
data Object The item being selected
tag
Source:

SelectionModel(options)

new SelectionModel(options)

Initializes the selections to be empty and mixes the passed object overriding any default properties.
Parameters:
Name Type Description
options Object The object to be mixed in.
Source:

Members

_fireEvents

Properties:
Name Type Description
Flag Boolean that control the firing of action events: onSelect, onDeselect, onClear
Source:

clearAsDeselect

Properties:
Name Type Description
Flag Boolean that determines how to clear: True: Deselect is called on every item, firing onDeselect for each and firing onClear at the end False: Collection is immediately wiped and only onClear is fired
Source:

count

Properties:
Name Type Description
Number Number of selections
Source:

requireSelection

Properties:
Name Type Description
Flag Boolean to indicate a selection is required.
Source:

selections

Properties:
Name Type Description
Collection Object of selections where the key is the selections key
Source:

Methods

clear()

Removes all items from the store
Source:

deselect(key)

Removes an item from the store
Parameters:
Name Type Description
key String Unique identifier string that was given when the item was added
Source:

getSelectedKeys() → {Array.<String>}

Returns a list of unique identifier keys used in the selection collection
Source:
Returns:
All keys in the store
Type
Array.<String>

getSelectionCount() → {Number}

Returns the number of items in the store
Source:
Returns:
Current count of items
Type
Number

getSelections() → {Object}

Returns all items in the store
Source:
Returns:
The entire selection collection
Type
Object

isSelected(key) → {Boolean}

Determines if the given key is in the selections collection.
Parameters:
Name Type Description
key String Unique identifier string that was given when the item was added
Source:
Returns:
True if the item is in the store.
Type
Boolean

onClear(self)

Event that happens when the store is cleared
Parameters:
Name Type Description
self
Source:

onDeselect(key, data, tag, self)

Event that happens when an item is deselected/removed.
Parameters:
Name Type Description
key String Unique identifier string
data Object The item removed
tag
self
Source:

onSelect(key, data, tag, self)

Event that happens when an item is selected/added.
Parameters:
Name Type Description
key String Unique identifier string
data Object The item stored
tag
self
Source:

resumeEvents()

Enables the firing of action events: onSelect, onDeselect, onClear
Source:

select(key, data, tag)

Adds an item to the `selections` if it is not already stored.
Parameters:
Name Type Description
key String Unique identifier string
data Object The item being selected
tag
Source:

suspendEvents()

Prevents the firing of action events: onSelect, onDeselect, onClear
Source:

toggle(key, data, tag)

Adds an item to the `selections` if it is not already stored, if it is stored, then it deselects (removes) the item.
Parameters:
Name Type Description
key String Unique identifier string
data Object The item being selected
tag
Source: