User Guide

290 Chapter 6: Components Dictionary
DataProvider API
ActionScript Class Name mx.controls.listclasses.DataProvider
The DataProvider API is a set of methods and properties that a data source needs so that a list-
based class can communicate with it. Arrays, recordsets, and data sets implement this API. You
can create a DataProvider-compliant class by implementing all the methods and properties
described in this section. A list-based component could then use that class as a data provider.
The methods of the DataProvider API 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 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 API,
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.
CHAPTER 6
Components Dictionary