Đang chuẩn bị liên kết để tải về tài liệu:
Flash Builder 4 and Flex 4 Bible- P14
Đang chuẩn bị nút TẢI XUỐNG, xin hãy chờ
Tải xuống
Flash Builder 4 and Flex 4 Bible- P14: When Macromedia first released Flash MX in 2002, the product was branded as the new way to build Rich Internet Applications (known by the acronym RIA). The term was invented at Macromedia to describe a new class of applications that would offer the benefits 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 applications since the mid-1990s | Chapter 20 Using Advanced List Controls On the Web The code in Listing 20.8 is available in the Web site files as DataGridFormatLabels.mxml in the chapter20 project. Figure 20.7 shows the resulting application with formatted phone numbers in the last column of the DataGrid control. FIGURE 20.7 A DataGridColumn with custom label formatting Using a dynamic data field As I described previously the custom formatting function for a DataGridColumn requires an argument that references the DataGridColumn that is calling the function. The purpose of this argument is to enable you to determine the data field of the current data item dynamically. For example if the data provider s data items have phone values in two different properties and you want to format them both with the same logic you can identify the property you want to format with the array-style expression item column.dataField . The dataField property of the DataGridColumn returns the name of the property currently being processed so you need only one custom function to format as many data properties as needed private function getPhoneLabel item Object column DataGridColumn String var dataValue String item column.dataField var pattern RegExp - g var phoneValue String dataValue.replace pattern return formatter.format phoneValue 621 Part III Working with Data Debugging a custom formatting function It can be instructive to add a trace statement to the body of a custom formatting function. As you scroll up and down in a DataGrid the trace statement in the custom function is executed each time the data grid column has to be formatted private function getPhoneLabel item Object column DataGridColumn String var dataValue String item column.dataField var pattern RegExp - g var phoneValue String item.phone.replace pattern trace original value dataValue formatted value formatter.format phoneValue return formatter.format phoneValue Figure 20.8 shows the resulting output in Flash Builder s Console view when the application is