Flex TileList 项目渲染器 +滚动=地狱
我对这个问题快要疯了。基本上,我有一个带有自定义项目渲染器的 TileList,其中有一个 TextInput。假设列表一次可以显示 4 个项目,如果有 5 个项目,并且我编辑第一个项目的文本,则第五个项目也会被编辑。一般来说,如果某个项目不在视图中,当我编辑正在显示的项目时,它会发生变化。
另外,我重写了 TileList 类以公开 rendererArray 属性(以便我可以访问每个渲染器上的文本),但它只会返回显示的渲染器。
任何帮助表示赞赏。我需要知道如何使用当前未显示的项目渲染器覆盖这种奇怪的行为。谢谢。
I'm going insane over this issue. Basically, I have a TileList with a custom item renderer that has a TextInput in it. Let's say that the list can show 4 items at once, if there are 5 items and I edit the text on the first one, the fifth will be edited also. In general if an item is out of view, it will be change when I edit one that is showing.
Also, I had overriden the TileList class to expose the rendererArray property (so that I could access the texts on each renderer) but it will only return the renderers which are displayed.
Any help is appreciated. I need to know how to override this weird behaviour with itemrenderers that aren't currently displayed. Thanks.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
好的,如果有人遇到类似的问题,您需要执行以下操作:
首先,避免像我一样尝试迭代 itemrenderers。如果您的 TileList 上需要 TextInput 或其他控件,请确保这些控件绑定到数据对象上的属性,否则屏幕外的项目将具有不正确的值,因为它们的项目渲染器将从离开屏幕的项目中回收。你滚动了。
如果您仔细考虑一下,任何需求都可以通过迭代 dataprovider 而不是 itemrenderers 来解决。
另外,如果您尝试像我一样公开 rendererArray 属性,请注意,您将只能迭代当前显示的项目渲染器,因为那些属于屏幕外项目的项目渲染器尚未创建。
我希望这不会太令人困惑..
Ok, if anyone runs into a similar issue, here is what you need to do:
First of all, avoid trying to iterate through the itemrenderers like I did. If you need a TextInput or another control on your TileList, make sure that these controls are bound to a property on your data object, otherwise off-screen items will have incorrect values since their itemrenderers will be recycled from the items that left the screen when you scrolled.
If you think it through, any requirement can be solved by iterating through the dataprovider instead of the itemrenderers.
Also, if you try to expose the rendererArray property like I did, notice that you will only be able to iterate through the itemrenderers that are currently displayed, since those that would belong to the items that are off-screen will not be created yet.
I hope this wasn't too confusing..