使用自定义项目渲染器对数据网格列进行缓慢排序
我们有一个包含 3 列的 Flex DataGrid,其中一列有一个自定义内联 itemrenderer,它根据行中的数据通过 Image 组件在单元格中呈现图标。
现在的问题是,对该列进行排序非常慢。当我们只有几行数据时,这是可以的,但是一旦我们有几百或几千行,我们就会注意到冻结了几秒钟。
有没有人注意到这一点并遇到同样的问题。如果是这样,您是否找到了解决此问题的好方法?我知道我们可以限制数据提供程序中的行数,但我真的在寻找根本问题的解决方案。
--
更新:有关解决方案的一些信息:我们遇到的问题实际上不是由项目渲染器引起的。由于该列中只有 2 个不同的值,因此在大型数据集上排序非常慢。解决方案是编写一个自定义比较函数,并将一些其他属性附加到要比较的值,以使其更加清晰。
We have a Flex DataGrid with 3 columns of which one of them has a custom inline itemrenderer that renders an icon in the cell via an Image component, depending on the data in the row.
The problem is now that sorting this column is incredibly slow. It's OK when we only have a few rows of data in there, but as soon as we have a few hundred or thousand of rows, we notice a freeze of several seconds.
Has anyone noticed this and run into the same problem. If so, did you find any good fix for this? I know we could limit the number of rows in the dataprovider, but I'm really looking for a solution to the root problem.
--
Update: some info on the solution: the problem we had was actually not caused by the item renderer. Since we only have 2 distinct values in that column, it was sorting really slow on large data sets. The solution was to write a custom compare function and append some of the other properties to the value that gets compared to make it more distinct.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我还没有在项目渲染器中看到过这种情况,但我确实看到当列中的数据非常相似时排序会变慢。例如,在我的 人口普查基准应用 中,Gender 列的排序速度比 Id 列慢得多。有一个已知错误,该错误有解决方法。
如果这不是问题,您只需要优化您的项目渲染器。查看默认 DataGridItemRenderer 的代码以查看优化良好的渲染器的示例。
I haven't seen this with item renderers but I certainly have seen sort get slow when the data in the column is very similar. For instance in my Census benchmark app the Gender column sorts much slower than the Id column. There is a known bug that has a workaround.
If that is not the problem they you will just need to optimize your item renderer. Check out the code the for default DataGridItemRenderer to see an example of a well optimized renderer.