views:

306

answers:

1

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.

+3  A: 

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.

James Ward
Shouldn't the impact of the used ItemRenderer be similar no matter how many items there are in the dataProvider? I thought they are being recycled, so that once they fill the whole visible part of the datagrid, their performance should be constant. I guess their data is only changed after the end of the sort, or is this not the case?
Robert Bak
It seems that we have the same issue. The column contains only 2 possible values and it sorts really slow with a lot of values (O(n²) worst case as it uses QuickSort). The fix was to write a custom compare function and append some of the other properties to the value to make it more distinct. Thanks James!
Christophe Herreman
Cool! I'm glad that was it. I wish that FP fixed this somehow.
James Ward