Sorting huge data in Adobe Flex

In Flex it is possible to load a very huge amount of data into an DataGrid/AdvancedDataGrid. A build in feature of a DataGrid is the column sorting.

About two years ago a colleague of mine had exactly this scenario. He had a DataGrid and he put a lot of data (about 20k rows) in it and tried so sort it. If he was lucky his system was blocked and the sorting was done but in most of the cases the Flashplayer gave an exception the script was running too long.

I searched around the web for this problem and found an entry in the Adobe Flex Jira System. Generally the Flex datagrid uses quicksort which should be fine, but if the data in a column doesn’t change often or if the datagrid contains a lot of data the sorting gets slow. What you see above is some demo application which I created to investigate the sorting problem. Click here or on the screenshot to get to the Demo Application.

The good news is in my solution 20k rows are absolutely no problem for sorting. Even 50k rows are ok on my machine (this depends on the CPU power of your system), 50k rows can also be handled by my Netbook.
I achieved this by using the workaround shown in Adobe Flex Jira System. The result was a lot better but the DueDate column sorted very slow. I asked again Google and the result was, that Flex doesn’t sort Date objects as Date objects but converts a Date object into an String and does then the comparation.
Of course this is slow. I tried custom sort functions in which i converted the Date object to milliseconds whithout big success. In the end I decided to get a Date object as Long from my Java backend and format the Date object in an ItemRender.

Feel free to sort some data or view the sourcecode by doing a mouse right click on the DataGrid in the running application.


Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s