View comments | RSS feed

DataProvider class

ActionScript Class Name mx.controls.listclasses.DataProvider

The methods of the DataProvider class let you query and modify the data in any component that displays data (also called a view). The DataProvider API also broadcasts change events when the data changes. Multiple views can use the same data provider and receive the change events.

A data provider is a linear collection (like an array) of items. Each item is an object composed of many fields of data. You can access these items by index (as you can with an array), using DataProvider.getItemAt().

Data providers are most commonly used with arrays. Data-aware components apply all the methods of the DataProvider API to Array.prototype when an Array object is in the same frame or screen as a data-aware component. This lets you use any existing array as the data for views that have a dataProvider property.

Because of the DataProvider API, the version 2 Macromedia Component Architecture components that provide views for data (DataGrid, List, Tree, and so on) can also display Flash Remoting RecordSet objects and data from the DataSet component. The DataProvider API is the language with which data-aware components communicate with their data providers.

In the Macromedia Flash documentation, "DataProvider" is the name of the class, dataProvider is a property of each component that acts as a view for data, and "data provider" is the generic term for a data source.

Method summary for the DataProvider API

The following table lists the methods of the DataProvider API.

Method

Description

DataProvider.addItem()

Adds an item at the end of the data provider.

DataProvider.addItemAt()

Adds an item to the data provider at the specified position.

DataProvider.editField()

Changes one field of the data provider.

DataProvider.getEditingData()

Gets the data for editing from a data provider.

DataProvider.getItemAt()

Gets a reference to the item at a specified position.

DataProvider.getItemID()

Returns the unique ID of the item.

DataProvider.removeAll()

Removes all items from a data provider.

DataProvider.removeItemAt()

Removes an item from a data provider at a specified position.

DataProvider.replaceItemAt()

Replaces the item at a specified position with another item.

DataProvider.sortItems()

Sorts the items in the data provider according to a compare function or sort options.

DataProvider.sortItemsBy()

Sorts the items in the data provider alphabetically or numerically, in the specified order, using the specified field name.

Property summary for the DataProvider API

The following table lists the properties of the DataProvider API.

Property

Description

DataProvider.length

The number of items in a data provider.

Event summary for the DataProvider API

The following table lists the events of the DataProvider API.

Event

Description

DataProvider.modelChanged

Broadcast when the data provider is changed.


Version 8

Comments


bbonet said on Jan 11, 2006 at 8:08 AM :
To clarify the above, you can create your own Data Provider extended list class, but if you want the Array type to utilize all of the Data Provider's Methods and Events you must use:

DataProvider.Initialize(Array);

This applies the Data Provider behavior to Array prototype.

 

RSS feed | Send me an e-mail when comments are added to this page | Comment Report

Current page: http://livedocs.adobe.com/flash/8/main/00003303.html