Adobe Flex Actionscript Question:
Download Questions PDF

How does item renderer work? How do we add item renderer at runtime in flex?

Answer:

Each list control has a default mechanism for controlling the display of data, or view, and lets you override that default. To override the default view, you create a custom item renderer.
Note: With reusable inline item renderers you use data binding to bind to the item renderer. When you use a component as an item renderer, you do not use data binding but specify the name of the custom component to use as an item renderer.

Add itemrendrer at run time:
Create the basic item renderer. One of the things I needed to accomplish with my item renderer was the ability to add it to different columns (ie the dataField was not always the same). This meant I needed a way from within the renderer to determine what column it was bound to so I could get and display the correct data. To do this the renderer needs to implement the IDropInListItemRenderer. This interface allows the renderer to have access to information about the list and column it is in via the BaseListData and DataGridListData classes. The DataGridListData gives you everything you need to get the data required to make a flexible, reusable renderer.
To Modify itemrenderer at runtime we Need to use mx.core.ClassFactory. Basically, in order to change a Flex itemRenderer at runtime, you need to cast it to a type ClassFactory.

Download Adobe Flex Actionscript Interview Questions And Answers PDF

Previous QuestionNext Question
What is state? what is the difference between states and ViewStack in flex?What keyword allows you to refer to private variables of a class in flex?