| Package | mx.controls.listClasses |
| Interface | public interface IDropInListItemRenderer |
| Implementors | Button, ComboBox, DataGridItemRenderer, DateField, Image, Label, ListBase, ListItemRenderer, MenuItemRenderer, NumericStepper, TextArea, TextInput, TileListItemRenderer, TreeItemRenderer |
text property. This
is easy to write using data-binding, but has the negative
consequence that the renderer cannot be re-used in another column
of a DataGrid or another List with different fields.
IDropInListItemRenderer allows a renderer to be re-used. The list
classes will pass more information to the renderer so that it
can determine which field to use at run-time.
Components that you want to use as drop-in item renderers or drop-in item editors must implement the IDropInListItemRenderer interface. Many Flex component implement this interface, and therefore are usable as drop-in item renderers and drop-in item editors in any column or list.
Drop-in item renderers or drop-in item editors also must implement
the IDataRenderer interface to define the data property.
When a component is used as a drop-in item renderer or drop-in
item editor, Flex initializes the listData property
of the component with the appropriate data from the list control.
The component can then use the listData property
to initialize the data property of the drop-in
item renderer or drop-in item editor.
The listData property is of type BaseListData,
where the BaseListData class has three subclasses:
DataGridListData, ListData, and TreeListData.
The actual data type of the value of the listData property
depends on the control using the drop-in item renderer or item editor.
For a DataGrid control, the value is of type DataGridListData,
for a List control the value is of type ListData,
and for a Tree control, the value is of type TreeListData.
The following example shows the setter method for the
data property for the NumericStepper control
that initializes NumericStepper's value property
based on the value of the listData property:
public function set data(value:Object):void
{
_data = value;
this.value = _listData ? parseFloat(_listData.label) : Number(_data);
dispatchEvent(new FlexEvent(FlexEvent.DATA_CHANGE));
}
In the example above, the NumericStepper control ignores the
data property when setting NumericStepper's
value property, and uses the listData
property instead.
To implement the IDropInListItemRenderer interface,
you define a setter and getter method to implement
the listData property.
Typically, the setter method writes the value of the
listData property to an internal variable.
The list class always assigns this property then sets
the data provider item in the data property.
Most implementations apply the listData
either in the data setter, or in
commitProperties() method because the data
setter called the invalidateProperties() method or
in response to the dataChange event because
the data setter dispatched the event.
The getter method returns the current value
of the internal variable, as the following example shows:
// Internal variable for the property value.
private var _listData:BaseListData;
// Make the listData property bindable.
[Bindable("dataChange")]
// Define the getter method.
public function get listData():BaseListData
{
return _listData;
}
// Define the setter method,
public function set listData(value:BaseListData):void
{
_listData = value;
}
See also
| Property | Defined by | ||
|---|---|---|---|
| listData : BaseListData
Implements the
listData property
using setter and getter methods. | IDropInListItemRenderer | ||
| listData | property |
listData:BaseListData [read-write]
Implements the listData property
using setter and getter methods.
public function get listData():BaseListData
public function set listData(value:BaseListData):void