Class YAHOO.widget.RecordSet
A RecordSet defines and manages a set of Records.
YAHOO.widget.RecordSet
(
data
)
- Parameters:
-
data
<Object || Object[]>
An object literal or an array of data.
_length
- private Number
Internal counter of how many Records are in the RecordSet.
_nCount
- private Number
Internal variable to give unique indexes to Record instances.
Internal class variable to name multiple Recordset instances.
private
YAHOO.widget.Record
_addRecord
(
oData
,
index
)
Adds one Record to the RecordSet at the given index. If index is null,
then adds the Record to the end of the RecordSet.
- Parameters:
-
oData <Object>
An object literal of data.
-
index <Number>
(optional) Position index.
- Returns:
YAHOO.widget.Record
- A Record instance.
private
void
_deleteRecord
(
index
,
range
)
Deletes Records from the RecordSet at the given index. If range is null,
then only one Record is deleted.
- Parameters:
-
index <Number>
Position index.
-
range <Number>
(optional) How many Records to delete
- Returns:
void
YAHOO.widget.Record
addRecord
(
oData
,
index
)
Adds one Record to the RecordSet at the given index. If index is null,
then adds the Record to the end of the RecordSet.
- Parameters:
-
oData <Object>
An object literal of data.
-
index <Number>
(optional) Position index.
- Returns:
YAHOO.widget.Record
- A Record instance.
YAHOO.widget.Record[]
addRecords
(
aData
,
index
)
Adds multiple Records at once to the RecordSet at the given index with the
given data. If index is null, then the new Records are added to the end of
the RecordSet.
- Parameters:
-
aData <Object[]>
An array of object literal data.
-
index <Number>
(optional) Position index.
- Returns:
YAHOO.widget.Record[]
- An array of Record instances.
Object
deleteRecord
(
index
,
range
)
Removes the Record at the given position index from the RecordSet. If a range
is also provided, removes that many Records, starting from the index. Length
of RecordSet is correspondingly shortened.
- Parameters:
-
index <Number>
Record's RecordSet position index.
-
range <Number>
(optional) How many Records to delete.
- Returns:
Object
- A copy of the data held by the deleted Record.
void
deleteRecords
(
index
,
range
)
Removes the Record at the given position index from the RecordSet. If a range
is also provided, removes that many Records, starting from the index. Length
of RecordSet is correspondingly shortened.
- Parameters:
-
index <Number>
Record's RecordSet position index.
-
range <Number>
(optional) How many Records to delete.
- Returns:
void
Number
getLength
(
)
Returns the number of Records held in the RecordSet.
- Returns:
Number
- Number of records in the RecordSet.
YAHOO.widget.Record
getRecord
(
index
)
Returns Record at given position index.
- Parameters:
-
index <Number>
Record's Recordset position index.
- Returns:
YAHOO.widget.Record
- Record object.
Number
getRecordIndex
(
oRecord
)
Returns position index for the given Record.
- Parameters:
-
oRecord <YAHOO.widget.Record>
Record instance.
- Returns:
Number
- Record's RecordSet position index.
YAHOO.widget.Record || YAHOO.widget.Record[]
replaceRecords
(
data
)
Replaces all Records in RecordSet with new data.
- Parameters:
-
data <Object || Object[]>
An object literal of data or an array of
object literal data.
- Returns:
YAHOO.widget.Record || YAHOO.widget.Record[]
- A Record instance or
an array of Records.
void
reset
(
)
Deletes all Records from the RecordSet.
YAHOO.widget.Record[]
sortRecords
(
fnSort
,
desc
)
Sorts all Records by given function.
- Parameters:
-
fnSort <Function>
Reference to a sort function.
-
desc <Boolean>
True if sort direction is descending, false if sort
direction is ascending.
- Returns:
YAHOO.widget.Record[]
- Sorted array of Records.
String
toString
(
)
Public accessor to the unique name of the RecordSet instance.
- Returns:
String
- Unique name of the RecordSet instance.
void
updateKey
(
record
,
sKey
,
oData
)
Updates given Record at given key with given data.
- Parameters:
-
record <YAHOO.widget.Record | Number>
A Record instance, or Record's
RecordSet position index.
-
sKey <String>
Key name.
-
oData <object>
{Object) New data.
- Returns:
void
YAHOO.widget.Record
updateRecord
(
record
,
oData
)
Updates given Record with given data.
- Parameters:
-
record <YAHOO.widget.Record | Number>
A Record instance, or Record's
RecordSet position index.
-
oData <object>
{Object) Object literal of new data.
- Returns:
YAHOO.widget.Record
- Updated Record, or null.
keyUpdateEvent
(
oArgs.record
,
oArgs.key
,
oArgs.newData
,
oArgs.oldData
)
Fired when a Record Key is updated with new data.
- Parameters:
-
oArgs.record <YAHOO.widget.Record>
The Record instance.
-
oArgs.key <String>
The updated key.
-
oArgs.newData <Object>
New data.
-
oArgs.oldData <Object>
Old data.
recordAddEvent
(
oArgs.record
,
oArgs.data
)
Fired when a new Record is added to the RecordSet.
- Parameters:
-
oArgs.record <YAHOO.widget.Record>
The Record instance.
-
oArgs.data <Object>
Data added.
recordDeleteEvent
(
oArgs.data
,
oArgs.index
)
Fired when a Record is deleted from the RecordSet.
- Parameters:
-
oArgs.data <Object>
A copy of the data held by the Record,
or an array of data object literals if multiple Records were deleted at once.
-
oArgs.index <Object>
Index of the deleted Record.
recordsAddEvent
(
oArgs.records
,
oArgs.data
)
Fired when multiple Records are added to the RecordSet at once.
- Parameters:
-
oArgs.records <YAHOO.widget.Record[]>
An array of Record instances.
-
oArgs.data <Object[]>
Data added.
recordsDeleteEvent
(
oArgs.data
,
oArgs.index
)
Fired when multiple Records are deleted from the RecordSet at once.
- Parameters:
-
oArgs.data <Object[]>
An array of data object literals copied
from the Records.
-
oArgs.index <Object>
Index of the first deleted Record.
recordUpdateEvent
(
oArgs.record
,
oArgs.newData
,
oArgs.oldData
)
Fired when a Record is updated with new data.
- Parameters:
-
oArgs.record <YAHOO.widget.Record>
The Record instance.
-
oArgs.newData <Object>
New data.
-
oArgs.oldData <Object>
Old data.
resetEvent
(
)
Fired when all Records are deleted from the RecordSet at once.