Chapter 22: Using Item Renderers and Item Editors--Creating drop-in item renderers and item editors
来源:互联网 发布:阳光网络logo图片素材 编辑:程序博客网 时间:2024/05/22 06:49
Several Flex controls are designed to work as item renderers and item editors. This lets you specify these controls
as values of the itemRenderer or itemEditor property. When you specify one of these controls as a property
value, it is called a drop-in item renderer or drop-in item editor.
To use a component as a drop-in item renderer or drop-in item editor, a component must implement the IDropIn-
ListItemRenderer interface. The following controls implement the IDropInListItemRenderer interface, making
them usable directly as a drop-in item renderer or drop-in item editor:
• Button
• CheckBox
• DateField
• Image
• Label
• NumericStepper
• Tex t
• Tex tAre a
• Tex t Input
You can define your own components for use as drop-in item renderers or drop-in item editors. The only
requirement is that they, too, implement the IDropInListItemRenderer interface.
Using drop-in item renderers and item editors
When you use a control as a drop-in item renderer, Flex sets the control’s default property to the current value of
the cell. When you use a control as an item editor, the initial value of the cell becomes the current value of the
control. Any edits made to the cell are copied back to the data provider of the list control.
Control
Default property
Notes
Button
selected
Cannot specify a label for the Button control.
CheckBox
selected
If used as a drop-in item renderer in a Tree control, the Tree displays only check boxes
with no text.
DateField
selectedDate
Requires that the data provider of the list control has a field of type Date.
Image
source
Set an explicit row height by using the rowHeight property, or set the variableRowHeight property to true to size the row correctly.
Label
text
NumericStepper
value
Text
text
TextArea
text
TextInput
text
In the following example, you use the NumericStepper, DateField, and CheckBox controls as the drop-in item
renderers and item editors for a DataGrid control:
To determine the field of the data provider used to populate the drop-in item renderer, Flex uses the value of the
dataField property for the <mx:DataGridColumn> tag. In this example, you do the following:
• You s e t t he dataField property of the second column to quant, and define the NumericStepper control as
the item editor. Therefore, the column displays the cell value as text, and opens the NumericStepper control when
you select the cell to edit it. The NumericStepper control displays the current value of the cell, and any changes
you make to it are copied back to the data provider of the DataGrid control.
• You set the dataField property of the third column to solddate, and define the DateField control as the item
renderer and item editor by setting the rendererIsEditor property to true. The data provider defines the data
as an object of type Date, which is required to use the DateField control as the item renderer or item editor.
Therefore, the column displays the date value using the DateField control, and also uses the DateField control to
edit the cell value.
• You s e t t he dataField property of the fourth column to Sent, and define the CheckBox control as the item
renderer and item editor. Typically, you use itemEditor property to specify a different class as the item editor,
and specify to use the same control as both the item renderer and item editor by setting the rendererIsEditor
property to true. The CheckBox control displays a check mark in the cell if the Sent field for the row is set to true,
and an empty check box if the field is set to false.
For more information on using an item renderer as an item editor, see “Creating an editable cell” on page 822.
Note: When you use a CheckBox control as a drop-in item renderer, the control appears flush against the left cell
border. To center a CheckBox control, or any drop-in item renderer, create a custom item renderer that wraps the
control in a container, such as the HBox container. However, the addition of the container can affect application
performance when you are rendering large amounts of data. For more information, see “Creating item renderers and
item editor components” on page 807.
When you use the Image control as a drop-in item renderer, you usually have to set the row height to accom-
modate the image, as the following example shows:
In this example, you use the Image control to display the album cover in a cell of the DataGrid control.
Requirements of a drop-in item renderer in a List control
When you use the itemRenderer property of the List control to specify a drop-in item renderer, the data in the
data provider must be of the type expected by the item renderer control. For example, if you use an Image control
as a drop-in item renderer, the data provider for the List control must have String data in the field.
- Chapter 22: Using Item Renderers and Item Editors--Creating drop-in item renderers and item editors
- Chapter 22: Using Item Renderers and Item Editors--Creating inline item renderers and editors
- Chapter 22: Using Item Renderers and Item Editors--Creating item renderers and item editor components
- Chapter 22: Using Item Renderers and Item Editors--Creating an item renderer and item editor
- Chapter 22: Using Item Renderers and Item Editors--About item renderers
- Flex lets you define item renderers and item editors in three different ways:
- Working with item renderers
- Creating and/or Removing a Login Item
- ITEM
- item
- item
- item
- item
- item
- 什么是drop-in item renderer
- Item Importer and Exporter
- item and material
- Creating List Item Folder
- 位域和sizeof
- poj 1828 Monkeys' Pride
- 我的大学(转自郭天祥)
- 构建高性能Web站点(笔记五)
- oracle listener 静态&动态注册
- Chapter 22: Using Item Renderers and Item Editors--Creating drop-in item renderers and item editors
- 关于像数据库输入中文显示乱码的问题
- 将两个有序链表合并成一个有序链表——搜狐畅游笔试题归来
- 没什么可写的
- 软件设计面向用户准则
- Annotation版本的hibernate
- 构建高性能Web站点(笔记八)
- Oracle Procedure中使用游标cursor更新多表
- 简单隐藏php,及自定义路由