本文介绍了强制所有项目渲染器commitProperties?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述 29岁程序员,3月因学历无情被辞! 我有一个项目渲染器检查外部源的显示信息。如果该信息发生变化,我想强制所有项目渲染器实例检查。 将列表或网格中的所有项目渲染器强制为 code> commitProperties 还是执行其他方法? grid.itemRenderer 属性将使都初始化。 我还收到了的建议,递归地遍历所有的网格的孩子,并调用 invalidateProperties所有UIComponent我找到的。 任何想法?备注?解决方案请记住,在Flex列表中,您正在处理虚拟化和itemRenderer回收,所以通常只有当前可见的itemRenderers存在,因此实际上需要更新。 以下内容适用于基于Spark列表的控件: for(var i:int = 0; i< sparkList.dataGroup.numElements; i ++) { var element:UIComponent = sparkList.dataGroup.getElementAt i)作为UIComponent; if(element) element.invalidateProperties(); else trace(element+ i.toString()+不存在); } 如果您有100个项目,则会更新10个可见的,忽略虚拟休息。 如果你正在使用mx DataGrid,你可能想尝试一个这样的变体,但是它不使用DataGroup / Spark虚拟化,所以我没有一个答案,你脱离了我的头。 PS我正在完成一个完全基于Spark的DataGrid,当我完成后,我会发布链接。 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 thegrid.itemRenderer property will makethem all initialize.I've also received the suggestion toiterate recursively through all thegrid's children and call invalidatePropertieson all the UIComponents I find.Any thoughts? Alternatives? 解决方案 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: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"); }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. 这篇关于强制所有项目渲染器commitProperties?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持! 上岸,阿里云!