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