Thông tin tài liệu:
Flash Builder 4 and Flex 4 Bible- P13: When Macromedia first released Flash MX in 2002, the product was branded as the newway to build Rich Internet Applications (known by the acronym RIA). The term wasinvented at Macromedia to describe a new class of applications that would offer thebenefits of being connected to the Internet, including access to various types of Web-based services,but would solve many of the nagging issues that had been inherent in browser-based applicationssince the mid-1990s....
Nội dung trích xuất từ tài liệu:
Flash Builder 4 and Flex 4 Bible- P13 CHAPTERUsing List ControlsM ost Flex applications are designed for the purpose of presenting and managing data in some form. As a result, one of the most pop- IN THIS CHAPTER ular families of visual controls in the Flex framework includes Understanding list controlsthose known as list controls. Providing data to list controlsA list control is defined as a component that has a dataProvider propertythat enables you to populate the control with dynamic data. The data provided Using dynamic data providersto a list control can be in the form of either hierarchical or relational data, and Controlling list item labelsthe type of data you want to present frequently determines which control youuse. In addition to being able to display relational or hierarchical data, list con- Using list control events andtrols have a common set of properties, methods, and events that enable the propertiesuser to select one or more items with mouse and keyboard gestures. Handling user data selectionsThe Flex 4 SDK includes both the older MX list controls such as DataGrid, Using custom item renderersAdvancedDataGrid, and OlapDataGrid and newer controls based onthe new Spark component architecture: l The List component. This component behaves by default like an HTML control and displays data items to the user in a list box. After you learn how to use the List control, you have most of the information you need to use other such controls. You can populate controls with data, listen for events indicating that the user has selected or started to drag data, set common styles, and so on. It supports the Spark layout architecture, so you can display a horizontal or tile layout instead of the default vertical list. l The DropDownList and ComboBox components. These compo- nents also behave like an HTML control but use a drop- down list instead of a static list. l The ButtonBar component. This component has the same appearance and behavior as an MX ToggleButtonBar, presenting a set of ToggleButton controls horizontally, but is controlled programmatically just like other Spark list controls. 571Part III: Working with DataOn the WebTo use the sample code for this chapter, import the chapter19.fxp project from the Web site files into anyfolder on your disk. n In this chapter, I describe in general terms how to use all list controls. I include information on how to populate these controls with data, how to control data presentation with custom generation of item labels and renderers, and how to handle events indicating that the user wants to select and manipulate data.Cross-ReferenceThe unique capabilities of other list controls, including the MX DataGrid, TileList, and HorizontalList,and the new Spark components, are described in Chapter 20. n Table 19.1 describes the components that have the capability to display dynamic data and support user interaction using the list control model. In the Architecture column I show which component architecture the most recent version of the component implements. TABLE 19.1 The List Controls Control Architecture Description Advanced MX This component implements all the features of the MX DataGrid DataGrid control but adds the capability to group and aggregate data and can sort on multiple columns. This component is part of the Flex Data Visualization components and is available only with a Flash Builder Premiere license. ButtonBar Spark This new component presents Spark ToggleButton objects horizontally. The appearance and behavior are similar to the MX ToggleButtonBar, but the application programming interface (API) follows the list model, implementing the change event and selected Item and selectedIndex properties. ComboBox Spark This component presents a drop-down list of simple string values. The ...