Search Flex Components Free

Custom Search

June 10, 2009

Questions in Flex

How does item renderer work? How do I add item renderer at runtime?
Item renderer is a class, that you use in a factory pattern. i.e. many controls that have to have repeatable parts that may be rendered using instances of some visual class may have item renderers.
Imagine this pseudo code:
[class ItemRenderer]
- set data();
- fieldA;
- fieldB;
[class VisualControl]
- factory = ItemRenderer;
- set data();

in VisualControl.[set data] you iterate through the collection of subsets of data and create new VisualControl.factory, then set that new VisualControl.factory instance's data property to that subset of data you want it to display.
say, your data looks like this:



Then, you'll create a VisualControl with 2 item renderers each of them will display in fieldA text "Lorem" and in fieldB "ipsum".

Related Flex Tutorials