Yahoo! UI Library

DataTable Widget  2.2.2

Yahoo! UI Library > datatable > RecordSet

Class RecordSet

A RecordSet defines and manages a set of Records.

Constructor

RecordSet ( data )
Parameters:
data <Object || Object[]> An object literal or an array of data.

Properties

_length - private object

Internal counter of how many records are in the RecordSet

_nCount - private static number

Internal class variable to index multiple data table instances.

_nIndex - private number

Instance index.

Methods

addRecord

YAHOO.widget.Record addRecord ( oObjectLiteral , 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:
oObjectLiteral <Object> An object literal of data.
index <Number> (optional) Position index.
Returns: YAHOO.widget.Record
A Record instance.

addRecords

YAHOO.widget.Record addRecords ( data , index )
Adds multiple Records to the RecordSet at the given index. If index is null, then adds the Records to the end of the RecordSet.
Parameters:
data <Object[]> An array of object literal data.
index <Number> (optional) Position index.
Returns: YAHOO.widget.Record
An array of Record instances.

append

YAHOO.widget.Record || YAHOO.widget.Record[] append ( data )
Convenience method to append the given data to the end of the RecordSet.
Parameters:
data <Object || Object[]> An object literal or array of data.
Returns: YAHOO.widget.Record || YAHOO.widget.Record[]
A Record or array of Records.

deleteRecord

void deleteRecord ( i , range )
Removes the record at the given index from the RecordSet. If a range is given, starts at the given index and removes all records in the range.
Parameters:
i <Number> Record index
range <Number> (optional) Range of records to remove, or null.
Returns: void

getLength

Number getLength ( )
Returns the number of non-null records in the sparse RecordSet
Returns: Number
Number records in the RecordSet

getRecord

Object getRecord ( identifier )
Returns record with given name, at the given index, or null.
Parameters:
identifier <String || Number> Record ID or record index
Returns: Object
Record object

getRecords

Array getRecords ( i , range )
Returns an array of Records from the RecordSet.
Parameters:
i <number> (optional) Index of which record to start at
range <number> (optional) Number of records to get
Returns: Array
Array of records starting at given index and lenth equal to given range. If i is null, entire RecordSet array is returned.

insert

YAHOO.widget.Record || YAHOO.widget.Record[] insert ( data )
Convenience method to insert the given data into the beginning of the RecordSet.
Parameters:
data <Object || Object[]> An object literal or array of data.
Returns: YAHOO.widget.Record || YAHOO.widget.Record[]
A Record or array of Records.

replace

YAHOO.widget.Record || YAHOO.widget.Record[] replace ( data )
Replaces all Records in RecordSet with new data.
Parameters:
data <Object || Object[]> An object literal or array or data.
Returns: YAHOO.widget.Record || YAHOO.widget.Record[]
A Record or array of Records.

reset

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

sort

Array sort ( fnSort )
Sorts RecordSet by given function.
Parameters:
fnSort <Function> Reference to a sort function.
Returns: Array
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

updateRecord

void updateRecord ( oRecord , sKey , oData )
Updates given Record at given key with given data.
Parameters:
oRecord <YAHOO.widget.Record> A Record instance.
sKey <String> Key.
oData <object> {Object) New data.
Returns: void

Events

recordUpdateEvent

recordUpdateEvent ( oArgs.record , oArgs.key , oArgs.newData , oArgs.oldData )
Fired when a Record is updated with new data.
Parameters:
oArgs.record <YAHOO.widget.Record> The Record instance.
oArgs.key <String> The Record key.
oArgs.newData <Object> New data.
oArgs.oldData <Object> Old data.


Copyright © 2007 Yahoo! Inc. All rights reserved.