|
|
|
I've uploaded an example of how to do this (SortExample.mxml) with screen shots. I'll start by saying I agree with the enhancement request (minor), but would like to comment on some of the individual statements made so far:
1) "it requires addition code": See the sample code; this can be done in a few lines. 2) "does not show the sort indicator in the sorted column": See the sample code and screen shots. If it doesn't for you, please attach sample code. 3) "when I sort a String column myself, It ignores case": See the sample code to see how to affect case sensitivity. 4) "To sort manually the data provider doesn't give the same result as the default datagrid's sorter.": If this happens in other ways besides the case sensitivity issue, can you let us know? Also, you can specify the sort function of a DataGridColumn if you want it to sort different than the DataGrid's default way. This won't make it into 3.0 because we're locked down, so please attach code, make comments, and let me know if you need any help with this. Thanks, - Rob Sending to IRB. Recommend for deferral.
Try to do it on a multi-colums datagrid.
Place this "custom" sorter on the first column to sort without case sensitive (like the first image) Launch it. Click on the second column header to sort it Click back to the first column header Then you can see that the sort order is case sensitive. So, users are desapointed. They first had a case insensitive sort order, and 2 clics later, they have a case sensitive sort order for the same column... Am I wrong ? Taking the example one step further, to make the DataGrid always deviate from its default sorting behavior when clicking on a column header, specify the sortCompareFunction of a DataGridColumn. it must specify a function with the signature:
mySortCompareFunction(obj1:Object, obj2:Object):int See SortingExample2.mxml, which has a DataGridColumn with a sortCompareFunction which reuses the doSort() function that was initially used. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Another reason :
To sort manually the data provider doesn't give the same résult as the default datagrid's sorter.
For example, when I sort a String column myself, It ignores case. When the datagrid sorts a String column, it sorts upper case first, and then lower case. So if I initialize by sorting myself the data provider and then, the user clic on the column header, he doesn't see the same result !!!
So it causes some "bizarre" incoherences...
Thanks