User Guide
DataGrid.editable 283
Description
Property; the data model for items viewed in a DataGrid component.
The data grid adds methods to the prototype of the Array class so that each Array object
conforms to the DataProvider API (see DataProvider.as in the Classes/mx/controls/listclasses
folder). Any array that is in the same frame or screen as a data grid automatically has all the
methods (
addItem(), getItemAt(), and so on) needed for it to be the data model of a data
grid, and can be used to broadcast data model changes to multiple components.
In a DataGrid component, you specify fields for display in the
DataGrid.columnNames
property. If you don’t define the column set (by setting the
DataGrid.columnNames property
or by calling
DataGrid.addColumn()) for the data grid before the DataGrid.dataProvider
property has been set, the data grid generates columns for each field in the data provider’s first
item, once that item arrives.
Any object that implements the DataProvider API can be used as a data provider for a data
grid (including Flash Remoting recordsets, data sets, and arrays). For example, see
“DataSet.dataProvider” on page 353.
Use a grid’s data provider to communicate with the data in the grid because the data provider
remains consistent, regardless of scroll position.
Example
The following example creates an array to be used as a data provider and assigns it directly to
the
dataProvider property:
my_dg.dataProvider = [{name:"Chris", price:"Priceless"}, {name:"Nigel",
price:"cheap"}];
The following example creates a new Array object that is decorated with the DataProvider
API. It uses a
for loop to add 20 items to the grid:
var myDP:Array = new Array();
for (var i=0; i<20; i++)
myDP.addItem({id:i, name:"Dave", price:"Priceless"});
my_dg.dataProvider = myDP
DataGrid.editable
Availability
Flash Player 6 (6.0.79.0).
Edition
Flash MX Professional 2004.