YUI recommends YUI 3.

YUI 2 has been deprecated since 2011. This site acts as an archive for files and documentation.

Yahoo! UI Library

DataTable Widget  2.3.1

Yahoo! UI Library > datatable > YAHOO.widget.RecordSet

Show Private Show Protected

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.

_sName - private String

Unique instance name.

RecordSet._nCount - private static Number

Internal class variable to name multiple Recordset instances.

Methods

_addRecord

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.

_deleteRecord

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

addRecord

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.

addRecords

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.

deleteRecord

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.

deleteRecords

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

getLength

Number getLength ( )
Returns the number of Records held in the RecordSet.
Returns: Number
Number of records in the RecordSet.

getRecord

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.

getRecordIndex

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.

getRecords

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.

replaceRecords

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.

reset

void reset ( )
Deletes all Records from the RecordSet.
Returns: void

sortRecords

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.

toString

String toString ( )
Public accessor to the unique name of the RecordSet instance.
Returns: String
Unique name of the RecordSet instance.

updateKey

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

updateRecord

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

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

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

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

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

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

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

resetEvent ( )
Fired when all Records are deleted from the RecordSet at once.


Copyright © 2007 Yahoo! Inc. All rights reserved.