强制所有项目渲染器提交属性? [英] Force all item renderers to commitProperties?

查看:25
本文介绍了强制所有项目渲染器提交属性?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个项目渲染器,用于检查外部来源的显示信息.如果该信息发生变化,我想强制所有项目渲染器实例进行检查.

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.

强制列表或网格中的所有项目渲染器commitProperties 或执行其他方法的最佳方法是什么?

What's the best way for force all the item renderers in a list or grid to either commitProperties or execute some other method?

  • 我读过重置grid.itemRenderer 属性将使他们都初始化.

  • I've read that resetting the grid.itemRenderer property will make them all initialize.

我也收到了建议递归遍历所有网格的孩子并调用 invalidateProperties在我找到的所有 UIComponent 上.

I've also received the suggestion to iterate recursively through all the grid's children and call invalidateProperties on all the UIComponents I find.

有什么想法吗?替代方案?

Any thoughts? Alternatives?

推荐答案

请记住,在 Flex Lists 中,您正在处理虚拟化和 itemRenderer 回收,因此通常只有当前可见的 itemRenderer 实际存在,因此才是真正需要的更新中.

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.

以下适用于基于 Spark 列表的控件:

The following works for Spark list-based controls:

for ( var i:int=0; i< sparkList.dataGroup.numElements; i++ )
            {
                var element:UIComponent = sparkList.dataGroup.getElementAt( i ) as UIComponent;
                if ( element )
                    element.invalidateProperties();
                else
                    trace("element " + i.toString() + " wasn't there");

            }

如果您有 100 个项目,这将更新 10 个可见的项目并忽略虚拟的其余部分.

If you've got 100 items, this will update the 10 visible ones and ignore the virtual rest.

如果您正在使用 mx DataGrid,您可能想尝试这种变体 - 但它不使用 DataGroup/Spark 虚拟化,因此我无法为您提供答案.

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.

附言我正在对完全基于 Spark 的 DataGrid 进行最后润色,完成后我会发布链接.

P.S. I'm putting the finishing touches on a completely Spark-based DataGrid, I'll post the link when I'm done.

这篇关于强制所有项目渲染器提交属性?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆