O'Reilly logo

Flex 4 Cookbook by Garth Braithwaite, Joshua Noble, Todd Anderson, Marco Casario, Rich Tretola

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

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 ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required