User Guide

258 DataGrid component (Flash Professional only)
Separate data processing from CellRenderer processing.
The CellRenderer API lets you display custom cell content in a data grid. A functional
requirement might require that you populate the data grid with a ComboBox component
or other UI control conditionally. For example, based on a selection in column two, you
may repopulate or auto-select options in column four. Whenever possible, it is important
to separate this conditional logic and repopulating of controls from the process of
rendering the content of the cell. Each time the mouse rolls over the cell, the cell is
selected, or data is changed, the content of the cell or the entire cell is likely to be redrawn
to keep it up to date. This means that any code you put in CellRenderer is run over and
over again, so you should keep processing in CellRenderer as light as possible. If you do
have to add code to CellRenderer, it is better to call a function from CellRenderer that
detects what updates need to be made and makes them in the most efficient manner.
Use UIObject.doLater() to access properties after the data grid has finished drawing.
A data grid instance needs to finish drawing and loading data before you can access all the
properties of the data grid (such as
focusedCell and others). Because there is no
complete” event for a DataGrid, you can use
UIObject.doLater(), instead, to call a
function that accesses the data grid properties.
UIObject.doLater() will execute the
function only after the data grid properties are available. See
DataGrid.focusedCell for
an example.
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
setSize() method (see
UIObject.setSize()). If there is no horizontal scroll bar, column widths adjust
proportionally. If column (and therefore, cell) size adjustment occurs, text in the cells may
be clipped.