Yahoo! UI Library

recordset  3.3.0

Yahoo! UI Library > recordset > Recordset
Search:
 
Filters

Class Recordset - extends Base

The Recordset utility provides a standard way for dealing with a collection of similar objects. Provides the base Recordset implementation, which can be extended to add additional functionality, such as custom indexing. sorting, and filtering.

Constructor

Recordset ( config )
Parameters:
config <Object> Configuration object literal with initial attribute values

Properties inherited from Plugin.Host:

Properties inherited from Attribute:

Properties inherited from Base:

Methods

_changeToRecord

private Y.Record _changeToRecord ( obj )
Helper method - it takes an object bag and converts it to a Y.Record
Parameters:
obj <Object || Y.Record> Any objet literal or Y.Record instance
Returns: Y.Record
A Record instance.

_defAddFn

private Y.Record _defAddFn ( )
Helper method called upon by add() - it is used to create a new record(s) in the recordset
Returns: Y.Record
A Record instance.

_defAddHash

private void _defAddHash ( )
Method called whenever "recordset:add" event is fired. It adds the new record(s) to the hashtable.

_defEmptyFn

private void _defEmptyFn ( )
Helper method called upon by empty() - it is used to empty the recordset

_defEmptyHash

private void _defEmptyHash ( )
Method called whenever "recordset:empty" event is fired. It empties the hash table.

_defRemoveFn

private void _defRemoveFn ( )
Helper method called upon by remove() - it is used to remove record(s) from the recordset

_defRemoveHash

private void _defRemoveHash ( )
Method called whenever "recordset:remove" event is fired. It removes the record(s) from the recordset.

_defUpdateFn

private void _defUpdateFn ( )
Helper method called upon by update() - it is used to update the recordset

_defUpdateHash

private void _defUpdateHash ( )
Method called whenever "recordset:update" event is fired. It updates the record(s) by adding the new ones and removing the overwritten ones.

_recordSetUpdated

private void _recordSetUpdated ( )
Event that is fired whenever the recordset is changed. Note that multiple simultaneous changes still fires this event once. (ie: Adding multiple records via an array will only fire this event once at the completion of all the additions)

_setHashTable

private void _setHashTable ( )
Sets up the hashtable with all the records currently in the recordset

_syncHashTable

private void _syncHashTable ( )
Syncs up the private hash methods with their appropriate triggering events.

add

Y.Recordset add ( oData , index )
Adds one or more Records to the RecordSet at the given index. If index is null, then adds the Records to the end of the RecordSet.
Parameters:
oData <Y.Record, Object Literal, Array> A Y.Record instance, An object literal of data or an array of object literals
index <Number> (optional) Index at which to add the record(s)
Returns: Y.Recordset
The updated recordset instance

empty

Y.Recordset empty ( )
Empties the recordset
Returns: Y.Recordset
The updated recordset instance

getLength

Number getLength ( )
Returns the length of the recordset
Returns: Number
Number of records in the recordset

getRecord

Y.Record getRecord ( i )
Returns the record with particular ID or index
Parameters:
i <String, Number> The ID of the record if a string, or the index if a number.
Returns: Y.Record
An Y.Record instance

getRecordByIndex

Y.Record getRecordByIndex ( i )
Returns the record at a particular index
Parameters:
i <Number> Index at which the required record resides
Returns: Y.Record
An Y.Record instance

getRecordsByIndex

Array getRecordsByIndex ( index , range )
Returns a range of records beginning at particular index
Parameters:
index <Number> Index at which the required record resides
range <Number> (Optional) Number of records to retrieve. The default is 1
Returns: Array
An array of Y.Record instances

getValuesByKey

Array getValuesByKey ( index )
Returns an array of values for a specified key in the recordset
Parameters:
index <Number> (optional) Index at which the required record resides
Returns: Array
An array of values for the given key

initializer

protected void initializer ( )
Publish default functions for events. Create the initial hash table.

remove

Y.Recordset remove ( index , range )
Removes one or more Records to the RecordSet at the given index. If index is null, then removes a single Record from the end of the RecordSet.
Parameters:
index <Number> (optional) Index at which to remove the record(s) from
range <Number> (optional) Number of records to remove (including the one at the index)
Returns: Y.Recordset
The updated recordset instance

update

Y.Recordset update ( data , index )
Updates the recordset with the new records passed in. Overwrites existing records when updating the index with the new records.
Parameters:
data <Y.Record, Object Literal, Array> A Y.Record instance, An object literal of data or an array of object literals
index <Number> (optional) The index to start updating from.
Returns: Y.Recordset
The updated recordset instance

Events

keyChange

keyChange ( event )
Fires when the value for the configuration attribute 'key' is changed. You can listen for the event using the on method if you wish to be notified before the attribute's value has changed, or using the after method if you wish to be notified after the attribute's value has changed.
Parameters:
event <Event.Facade> An Event Facade object with the following attribute specific properties added:
prevVal
The value of the attribute, prior to it being set
newVal
The value the attribute is to be set to
attrName
The name of the attribute being set
subAttrName
If setting a property within the attribute's value, the name of the sub-attribute property being set

recordsChange

recordsChange ( event )
Fires when the value for the configuration attribute 'records' is changed. You can listen for the event using the on method if you wish to be notified before the attribute's value has changed, or using the after method if you wish to be notified after the attribute's value has changed.
Parameters:
event <Event.Facade> An Event Facade object with the following attribute specific properties added:
prevVal
The value of the attribute, prior to it being set
newVal
The value the attribute is to be set to
attrName
The name of the attribute being set
subAttrName
If setting a property within the attribute's value, the name of the sub-attribute property being set

tableChange

tableChange ( event )
Fires when the value for the configuration attribute 'table' is changed. You can listen for the event using the on method if you wish to be notified before the attribute's value has changed, or using the after method if you wish to be notified after the attribute's value has changed.
Parameters:
event <Event.Facade> An Event Facade object with the following attribute specific properties added:
prevVal
The value of the attribute, prior to it being set
newVal
The value the attribute is to be set to
attrName
The name of the attribute being set
subAttrName
If setting a property within the attribute's value, the name of the sub-attribute property being set

Events inherited from Base:

Configuration Attributes

key - string

The ID to use as the key in the hash table.

records - array

An array of records that the recordset is storing

table - object

A hash table where the ID of the record is the key, and the record instance is the value.

Configuration attributes inherited from Base:


Copyright © 2011 Yahoo! Inc. All rights reserved.