更改列表项渲染取决于视图状态
我有一个列表,该项目呈现如下:链接。 但现在我需要启用或禁用删除按钮取决于我的列表所在的视图状态。
这是我的视图(包含列表):
<s:states>
<s:State name="main" /> <!-- Navigation.CART_MAIN -->
<s:State name="cash" /> <!-- Navigation.CART_CASH -->
<s:State name="credit" /> <!-- Navigation.CART_CREDIT -->
</s:states>
<s:List id="theList"
width="480" height="240"
x="69" y="82"
dataProvider="{model.products}"
useVirtualLayout="false"
itemRenderer="com.png.vm.ui.components.ProductCartThumbnail" >
</s:List>
问题是我只想在屏幕使用状态“main”时启用 itemRender 内的删除按钮
I have one list, which the item render it`s like this:link.
But now I need to enable or disable the button delete depends the view state which my List is inside.
This is my view(which contains the list):
<s:states>
<s:State name="main" /> <!-- Navigation.CART_MAIN -->
<s:State name="cash" /> <!-- Navigation.CART_CASH -->
<s:State name="credit" /> <!-- Navigation.CART_CREDIT -->
</s:states>
<s:List id="theList"
width="480" height="240"
x="69" y="82"
dataProvider="{model.products}"
useVirtualLayout="false"
itemRenderer="com.png.vm.ui.components.ProductCartThumbnail" >
</s:List>
The thing is that I just want to enable the delete buttons inside the itemRender when the screen is using the state "main"
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
另一种选择是创建单独的 itemRenderer 并使用 itemRendererFunction。
我从之前提出的类似问题中获取了这个示例,并对其进行了一些修改以满足您的需求:
flex 4 list ItemRenderer:我如何为不同的行拥有不同的itemrenderers?
编辑:
这是使用的另一种解决方案。您可以通过为每个状态声明不同的属性值来指定不同的 itemRenderer。
Another option would be to create separate itemRenderers and use the itemRendererFunction.
I've taken this example from similar question that was asked earlier and modified it a bit to suit your needs:
flex 4 list ItemRenderer: how can i have different itemrenderers for different rows?
EDIT:
Here's the other solution that was used. You can designate different itemRenderers by declaring different property values for each state.
我遇到了完全相同的问题。
我注入了模型状态(例如 modelState),它确定渲染器类中按钮的状态。
是的,我知道这不是最好的决定!
I got exactly the same problem.
I injected the model state (modelState for example) which determines the state of the buttons in the renderer class.
Yes, I know that this is not the best decision!