Bug: Workaround For SortField bug in DataGrid

Several people have run into this bug (SDK-9398) where the SortField that you set for one of your DataGrid columns get clobbered after the user sorts a different column. In current builds of Flex, the DataGrid code re-sets the fields array on the Sort object to the SortField in current “play” clearing any other SortFields previously set on the collection. It doesn’t look like the bug is going to get fixed any time soon, so I was tasked with finding a workaround today.

You can see the problem in this example by sorting the various columns. After sorting the ‘birthday’ column in this example, the ‘name’ column loses its SortField which specified that its sorting should be case sensitive:

Demo of Bug: originalSortBug.swf

Source of Bug File: originalSortBug.mxml

I found a workaround for the bug where you reset the SortField every time a user clicks on the a DataGridColumn header. So, in my workaround, I listen for the headerRelease event and reset the SortField at this time. Here is an example that uses the workaround:

Demo of Workaround: sortingBug.swf

Source for Workaround: sortingBug.mxml

Leave a Reply

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

WordPress.com Logo

You are commenting using your WordPress.com 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

%d bloggers like this: