InterviewSolution
| 1. |
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. 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 runtirne, you need to cast it to a type ClassFactory. 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. 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 runtirne, you need to cast it to a type ClassFactory. |
|