Chapter 9. DataGrid
The DataGrid control is a
list-based control optimized to display large data sets in a multicolumn
layout. It features resizable columns, customizable item renderers, and
sorting capabilities, among other features. As of the writing of this book,
the DataGrid component only has a Halo or
mx-prefixed version. The Spark component
is still forthcoming, so all of the recipes in this chapter will use Halo
components. Some recipes, however, do show how to use the Spark ItemRenderer or other Spark components within a
Flex DataGrid.
The DataGrid control (and its
sister AdvancedDataGrid, included in the
Data Visualization package for Flex 4) is typically used to display arrays
or collections of data objects with similar types. The DataGrid control can also display HierarchicalData objects, show the parent/child
relationships among complex data objects, and allow for the creation of
specialized groupings of data, although, as you’ll see, this is easier to do
with AdvancedDataGrid.
9.1. Create Custom Columns for a DataGrid
Problem
You need to specify custom columns for a DataGrid and explicitly control the
display.
Solution
Use the DataGridColumn tag to
specify custom properties for columns in a DataGrid.
Discussion
This recipe adds three DataGridColumn tags to the columns property of a DataGrid. It uses a data file titled homesforsale.xml, although the data that you
use could have any name and represent any array of information. The
DataGridColumn tags specify the order in which ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access