How to avoid loads of 'if statements' in item renderers
I have an item renderer for a list containing an image, label and a checkbox.
These are visible depending on the dataProvider property of the list.
Eg if an image is a premium image then display the premium label, if an image is a favourite then display a star etc.
The problem is i have a massive if statement, and this doesn't seem good practice.
So how can i seperate the logic from the display components?
Thanks
You don't say what version of Flex you are using. In Flex 4, you could use States and then use includeIn based on the State. If you're using Flex 3, you might want to look at the TileList_withStyle and DataGrid_withStyle at flexdiary.blogspot.com, and do this with styles.
You may also want to look at Robotlegs. I have done this kind of thing in the past by using a Mediator to "watch" the data on a renderer and turn things on and off inside a renderer.
链接地址: http://www.djcxy.com/p/5914.html上一篇: 列表中的Flex移动项目渲染器
下一篇: 如何避免在项目渲染器中加载“if语句”