Class YAHOO.widget.RecordSet
A RecordSet defines and manages a set of Records.
Constructor
YAHOO.widget.RecordSet
(
data
)
- Parameters:
-
data
<Object || Object[]>
An object literal or an array of data.
Properties
_length
- private Number
Internal counter of how many Records are in the RecordSet.
Internal class variable to name multiple Recordset instances.
Methods
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
(
record
)
Returns Record by ID or RecordSet position index.
- Parameters:
-
record <YAHOO.widget.Record | Number | String>
Record instance,
RecordSet position index, or Record ID.
- Returns:
YAHOO.widget.Record
- Record object.
Number
getRecordIndex
(
oRecord
)
Returns current position index for the given Record.
- Parameters:
-
oRecord <YAHOO.widget.Record>
Record instance.
- Returns:
Number
- Record's RecordSet position index.
YAHOO.widget.Record[]
getRecords
(
index
,
range
)
Returns an array of Records from the RecordSet.
- Parameters:
-
index <Number>
(optional) Recordset position index of which Record to
start at.
-
range <Number>
(optional) Number of Records to get.
- Returns:
YAHOO.widget.Record[]
- Array of Records starting at given index and
length equal to given range. If index is not given, all Records are returned.
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. Records keep their unique IDs but will
have new RecordSet position indexes.
- 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 | String>
A Record instance,
a RecordSet position index, or a Record ID.
-
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 | String>
A Record instance,
a RecordSet position index, or a Record ID.
-
oData <object>
{Object) Object literal of new data.
- Returns:
YAHOO.widget.Record
- Updated Record, or null.
Events
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.