Creating an application with the DataGrid component
To create an application with the DataGrid component, you must first determine where your data
is coming from. The data for a grid can come from a recordset that is fed from a database query in
Macromedia ColdFusion, Java, or .Net using Flash Remoting. Data can also come from a data set
or an array. To pull the data into a grid, you set the
recordset, data set, or array. You can also use the methods of the DataGrid and DataGridColumn
classes to create data locally. Any Array object in the same frame as a DataGrid component copies
the methods, properties, and events of the DataProvider API.
To use Flash Remoting to add a DataGrid component to an application:
In Flash, select File > New and select Flash Document.
1.
In the Components panel, double-click the DataGrid component to add it to the Stage.
2.
In the Property inspector, enter the instance name myDataGrid.
3.
In the Actions panel on Frame 1, enter the following code:
4.
myDataGrid.dataProvider = recordSetInstance;
The Flash Remoting recordset
of
myDataGrid
Select Control > Test Movie.
5.
To use a local data provider to add a DataGrid component to an application:
In Flash, select File > New and select Flash Document.
1.
In the Components panel, double-click the DataGrid component to add it to the Stage.
2.
In the Property inspector, enter the instance name myDataGrid.
3.
In the Actions panel on Frame 1, enter the following code:
4.
myDP = new Array({name:"Chris", price:"Priceless"}, {name:"Nigel",
price:"Cheap"});
myDataGrid.dataProvider = myDP;
The
and
name
each row.
Select Control > Test Movie.
5.
Customizing the DataGrid component (Flash Professional only)
You can transform a DataGrid component horizontally and vertically during authoring and
runtime. While authoring, select the component on the Stage and use the Free Transform tool or
any of the Modify > Transform commands. At runtime, use the
UIObject.setSize()
If column (and therefore, cell) size adjustment occurs, text in the cells may be clipped.
recordSetInstance
.
fields are used as the column headings, and their values fill the cells in
price
). If there is no horizontal scroll bar, column widths adjust proportionally.
DataGrid.dataProvider
is assigned to the
setSize()
DataGrid component (Flash Professional only)
property to the
property
dataProvider
method (see
251
Need help?
Do you have a question about the FLASH MX 2004-USING COMPONENTS and is the answer not in the manual?