Spark List 重用了错误的项目渲染器

发布于 2024-08-21 00:01:46 字数 219 浏览 7 评论 0原文

我有一个 List 组件,使用由 itemRendererFunction 确定的多个项目渲染器。当我第一次设置数据时,它按预期工作。然后,当我使用新数据第二次设置数据时,它不会调用 itemRendererFunction 并尝试重用当前渲染器,即使它们与数据不匹配。一旦我滚动,就会调用该函数并使用正确的渲染器。我尝试在设置数据之前调用 invalidateDisplayList 等,但这并没有解决问题。有什么想法吗?

I have a List component using multiple item renderers determined by the itemRendererFunction. When I set the data the first time, it works as expected. Then, when I set the data a second time with new data, it doesn't call the itemRendererFunction and tries to reuse the current renderers even though they don't match the data. Once I scroll, the function is called and the correct renderers are used. I tried calling invalidateDisplayList and such prior to setting the data, but that didn't fix the problem. Any ideas?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

风吹雪碎 2024-08-28 00:01:46

事实证明这是一个 Flex SDK 错误。 Peter DeHaan 为我提供了一种解决方法(在设置 dataProvider 之后重新设置 itemRendererFunction 属性),并正在将其归档以用于 SDK 的未来版本。

It turns out this is a Flex SDK bug. Peter DeHaan provided me with a workaround (re-setting the itemRendererFunction property after the dataProvider is set) and is filing it for a future release of the SDK.

做个少女永远怀春 2024-08-28 00:01:46

这里只是一些想法:

尝试 invalidateProperties?查看源代码,我有一种预感,否则,也许只是开始调用您能找到的每个无效方法,直到找到正确的方法为止。

另一个有点黑客的解决方案可能是不采用当前滚动位置(通过列表上的滚动条)将新数组作为数据提供者传递(这肯定会重新创建项目渲染器),然后将滚动位置设置为与之前的滚动位置相同。刷新。

或者您可以将不同项目渲染器的选择抽象到项目渲染器本身中。 :/

Here's just some ideas:

Try invalidateProperties? Looking at the source I have a hunch it could be that, otherwise, perhaps just start calling every invalidate method you can find till you get the right one.

Another sorta hacky solution might be to take not of current scrolling position (via the scroller on the List) pass in a new array as dataprovider (which will definitely recreate the item renderers) then set the scroll position to the same as it was before the refresh.

Or you could abstract out the selection of the different item renderer into the item renderer itself. :/

じ违心 2024-08-28 00:01:46

FWIW:这是 Flex bug 的链接:
https://bugs.adobe.com/jira/browse/SDK-32018

FWIW: Here's the link to the Flex bug:
https://bugs.adobe.com/jira/browse/SDK-32018

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文