DataSetDataProvider

Kind of class:class
Inherits from:Object
Classpath:mx.data.components.datasetclasses.DataSetDataProvider
File last modified:Tuesday, 18 December 2007, 15:44:38
Provides the DataProvider API for the DataSet. This is implemented as a separate
class so that calls made to the API are known as DataProvider API calls. This
is required since the DataProvider does not support any formatting of

Summary


Constructor
  • DataSetDataProvider (aDataSet:Object)
    • Construcs a new instance of the DataProvider API for the specified DataSet
Instance properties
Instance methods
  • addEventListener (eventName:String, handler) : Void
    • Makes sure that the listener for this is actually listening to the DataSet.
  • addItem (item:Object) : Void
    • Adds the specified item to the collection for management
  • addItemAt (index:Number, transferObj:Object) : Void
    • Adds the specified transfer object to the collection for
  • editField (index:Number, fieldName:String, newData:Object) : Void
    • Changes one transfer object's property within this collection.
  • getColumnNames : Array
    • Returns the list of column names for the DataSet.
  • getEditingData (index:Number, fieldName:String) : Object
    • Returns The editable-formatted data to be used.
  • getItemAt (index:Number) : Object
    • Returns the display view of the transfer object at the specified index.
  • getItemID (index:Number) : String
    • Returns the identifier of the current transfer object within the collection.
  • removeAll : Void
    • This method will clear all of the items in the collection regardless of what the
  • removeItemAt (index:Number) : Void
    • Removes the transfer object from the collection at the specified index.
  • replaceItemAt (index:Number, item:Object) : Void
    • Replaces the contents of the item at the index specified.
  • sortItemsBy (fieldNames, options) : Void
    • Sorts the items within the DataSet collection by the specified fields and options
  • isFieldReadOnly (name:String) : Boolean

Constructor

DataSetDataProvider

function DataSetDataProvider (
aDataSet:Object)

Construcs a new instance of the DataProvider API for the specified DataSet
Parameters:
aDataSet:
Object reference to the DataSet this DP API is representing

Instance properties

_dataset

private _dataset:Object
(read)

_desiredTypes

private _desiredTypes:Object
(read)

_dg

(read)

_dgInit

private _dgInit:Boolean
(read)

length

length:Number
(read)

Read-only; returns the length of the items in the data provider.

Instance methods

addEventListener

function addEventListener (
eventName:String, handler) : Void

Makes sure that the listener for this is actually listening to the DataSet.
It is the DataSet that will dispatch the modelChanged event.
Parameters:
eventName:
String containing the name of the desired event
handler :
function or object that will handle the event specified

addItem

function addItem (
item:Object) : Void

Adds the specified item to the collection for management
Parameters:
item:
Object transfer object to add to the collection

addItemAt

function addItemAt (
index:Number, transferObj:Object) : Void

Adds the specified transfer object to the collection for
management at the specified location.
Parameters:
index :
Number contaning the desired position within the collection
transferObj:
Object transfer object to manage within this DataSet collection
Example:
  • myDataSet.dataProvider.addItemAt( 10, myDataSet.createItem());

editField

function editField (
index:Number, fieldName:String, newData:Object) : Void

Changes one transfer object's property within this collection.
Parameters:
index :
Number >= 0. The index of the item. Fails if out of range
fieldName:
String, the name of the field in the item to modify. Fails if non-existent.
newData :
Object - the new data to put in the dp.
tiptext Sets new value for specified field
helpid 3400@eaxmple
// Modify the "label" of the 3rd item.
myDataSet.dataProvider.editField( 2, "notes", "here are some new notes." );

getColumnNames

function getColumnNames (
) : Array

Returns the list of column names for the DataSet.

tiptext Returns array of property names
helpid 3400
Returns:
  • Array of Strings containing the labels to use for a column heading

getEditingData

function getEditingData (
index:Number, fieldName:String) : Object

Returns The editable-formatted data to be used. This allows the model to provide different
formats of data for editing than for displaying.
Parameters:
index :
Number. (index>=0) and (index
fieldName:
String the name of the field being edited.
tiptext Returns the unformatted property value specified
helpid 3400
Example:
  • // getting an editable string for the price field
    trace( myDataSet.getEditingData( 4, "price" );

getItemAt

function getItemAt (
index:Number) : Object

Returns the display view of the transfer object at the specified index.
Parameters:
index:
Number. (index>=0) and (index
Returns:
  • Object transfer object at the specified index within this collection or
    undefined if index is out of range.
    tiptext Returns the item at the specified location
    helpid 3400

getItemID

function getItemID (
index:Number) : String

Returns the identifier of the current transfer object within the collection.
Parameters:
index:
Number [optional] specifing the index of the item we want the ID for,
if not specified gets the id for the current item.
Returns:
  • Number unique identifier for this item within this collection
Example:
  • var itemNo:Number = myDataSet.getItemID();
    displayStatusBarMsg( "Employee id("+ itemNo+ ")");

isFieldReadOnly

private function isFieldReadOnly (
name:String) : Boolean

removeAll

function removeAll (
) : Void

This method will clear all of the items in the collection regardless of what the
default or current iterator's view of this collection is. If logChanges is true each
item removed will be logged as such in the delta packet.

removeItemAt

function removeItemAt (
index:Number) : Void

Removes the transfer object from the collection at the specified index. This operation will be
logged to the delta packet if logChanges is true. If the specified transfer object does not exist
this method will do nothing.
Parameters:
index:
Number index of the item to remove
Example:
  • var emp:Employee = myManagementDataSet.currentItem();
    myManagementDataSet.removeItemAt( 5 );
    // give him a promotion
    myJanitorDataSet.addItem( emp );

replaceItemAt

function replaceItemAt (
index:Number, item:Object) : Void

Replaces the contents of the item at the index specified. This method will call
removeItemAt() and then addItemAt(). If logChanges is true this method will
create two entries in the delta packet. Depedning on the sorting specified for
the default or current iterator the item may not show up at the index specified.
Parameters:
index:
Number >= 0. The index of the item to change.
item :
Object the new transfer object to replace
Example:
  • // Change the fourth item.
    myDataSet.replaceItemAt( 3, new Employee( "Bob", "Smith" ));

sortItemsBy

function sortItemsBy (
fieldNames, options) : Void

Sorts the items within the DataSet collection by the specified fields and options
Parameters:
fieldNames:
a single field name or a list of field names in an array to sort
the items in the collection by.
options :
a string containing either "ASC" or "DESC", or a number containing the
options to sort the collection with