Flex 2.0 ItemRenderers

Mixing it all together
Nathan Daniel
A web developer specializing in web services and integration. Along with HTML & PHP development, Nathan also develops RIAs utilizing Flex 2.0 and Flash!
Online portfolio and website can be seen at http://flex2.bsi-scs.com.
The final step is to implement your new component. Open source view of the main application and replace labelField="label" with itemRenderer="ListItem" (ListItem is the name of my component I created, if you named your something different, it should be changed to match the name of your component).
From:
<mx:List id="myList" dataProvider="{myArray}" labelField="label" width="200" left="10" top="10"/>
To:
<mx:List id="myList" dataProvider="{myArray}" itemRenderer="ListItem" width="200" left="10" top="10"/>
That's it! Run your application and your list items will now be your new component!
The beauty of the ItemRenderer is it can be used in ALL list based components - List, TileList, ComboBox, etc. Using the ItemRenderer, you can change a ComboBox component to include more than just text as a choice - it can be an image! Great for a product catalog or anything else you could image!
Spread The Word
4 Responses to "Flex 2.0 ItemRenderers" 
|
said this on 04 May 2007 1:06:18 AM CDT
great tutorial... but I didn't understand to give name "ListItem" to which component?
|
|
said this on 30 Aug 2007 4:07:57 PM CDT
Say I use an itemRenderer as you describe above, but I want to use it to format text in a list or data grid...how can I dynamically reference the value of the data provider that I need in the current cell or list item? Is there no direct way to reference the parent of the itemRenderer?
|
|
said this on 10 Jan 2008 2:40:02 AM CDT
the syntax of the displayed code is not correct
...Array({label="item... should be ...Array({label:"item... It cost nerves to find thing this kind of things and especially if you are new to a subject! Please be careful. |
|
said this on 15 May 2008 10:21:50 AM CDT
Is there a way of knowing from inside the itemRenderer whether it's an odd or even instance, ie alternatingItemColors?
|



Author/Admin)