强制所有项目渲染器提交属性?
我有一个项目渲染器,用于检查外部源的显示信息。如果该信息发生变化,我想强制所有项目渲染器实例检查它。
强制列表或网格中的所有项目渲染器 commitProperties
或执行其他方法的最佳方法是什么?
我读过重置
grid.itemRenderer
属性将使 它们都初始化。我也收到了建议 递归地迭代所有 网格的子级并调用
invalidateProperties
在我找到的所有 UIComponents 上。
有什么想法吗?替代品?
I have an item renderer that checks an external source for display information. If that information changes, I want to force all item renderer instances to check it.
What's the best way for force all the item renderers in a list or grid to either commitProperties
or execute some other method?
I've read that resetting the
grid.itemRenderer
property will make
them all initialize.I've also received the suggestion to
iterate recursively through all the
grid's children and callinvalidateProperties
on all the UIComponents I find.
Any thoughts? Alternatives?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
请记住,在 Flex Lists 中,您正在处理虚拟化和 itemRenderer 回收,因此通常只有当前可见的 itemRenderer 实际存在,因此才是实际需要更新的 itemRenderer。
以下适用于 Spark 基于列表的控件:
如果您有 100 个项目,这将更新 10 个可见项目并忽略虚拟其余项目。
如果您正在使用 mx DataGrid,您可能想尝试它的变体 - 但它不使用 DataGroup / Spark 虚拟化,因此我无法立即为您提供答案。
PS 我正在对完全基于 Spark 的 DataGrid 进行最后的修饰,完成后我将发布链接。
Remember that in Flex Lists you're dealing with virtualization and itemRenderer recycling, so generally only the currently visible itemRenderers actually exist, and are therefore the ones that actually need updating.
The following works for Spark list-based controls:
If you've got 100 items, this will update the 10 visible ones and ignore the virtual rest.
If you're working with mx DataGrid, you might want to try a variant of this- but it doesn't use DataGroup / Spark virtualization so I don't have an answer for you off the top of my head.
P.S. I'm putting the finishing touches on a completely Spark-based DataGrid, I'll post the link when I'm done.
Datagroup 有 getItemIndicesInView() ,它将为您提供视图中所有项目渲染器的索引。使用这些索引调用 getElementAt。
我通常还扩展 ItemRenderer 并添加以下内容,这将导致项目渲染器的状态刷新。
Datagroup has getItemIndicesInView() which will give you the indicies of all item renderers that are in view. Call getElementAt with those indicies.
I also usually extend ItemRenderer and add the following which will cause the item renderer's state to refresh.
对我来说效果很好
works fine for me