User Guide

DataGrid component (Flash Professional only) 269
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 dont 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 providers 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).
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:
grid.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:
myDP = new Array();
for (var i=0; i<20; i++)
myDP.addItem({name:"Nivesh", price:"Priceless"});
list.dataProvider = myDP
DataGrid.editable
Availability
Flash Player 6 (6.0 79.0).
Edition
Flash MX Professional 2004.
Usage
myDataGrid.editable
Description
Property; determines whether the data grid can be edited by a user (true) or not (false). This
property must be
true in order for individual columns to be editable and for any cell to receive
focus. The default value is
false.
If you want individual columns to be uneditable, use the
DataGridColumn.editable property.