Thanks so much, I got it working with this forum's feedback. ----- Original Message ----- From: "Mark Kessler" <[email protected]> To: "Users@flex" <[email protected]> Sent: Monday, September 2, 2013 7:43:13 AM Subject: Re: how to perform secondary sort on spark datagrid?
Using your own sorting handler for the dataProvider. ListCollectionView (ArrayCollection, XMLListCollection) have a "sort" (iSort) property [1]. Create a new "Array" to add new "SortField"'s to. These have properties like descending and numeric. The last thing to do is to handle "SortChanging" event on the data grid so you can "preventDefault()" its standard sort behavior. Only two caveats... 1. An empty sort array will cause the default sorting action (eg it will sort it through all it's fields on it's own). 2. The DataGrid's sort indicator doesn't keep track of all the columns. There are ways to ways to add that functionality too, but difficult and inconsistent. I have not used the DataGrid.multiColumnSortingEnabled property yet (new), but I bet it doesn't keep track of numeric sorting. I may take a look at it to see if it does or not. If it doesn't I'll add that functionality in. [1] http://flex.apache.org/asdoc/mx/collections/ListCollectionView.html#sort [2] http://flex.apache.org/asdoc/spark/collections/SortField.html -Mark On Sun, Sep 1, 2013 at 9:55 PM, <[email protected]> wrote: > If I have a standard spark datagrid and click on a column to sort it, can > I somehow program a second column as a secondary sort? > > That is, the first column, which the user clicks on, is sorted, then a > predetermined second column is programmatically sorted. > > For example, the user clicks col2 to sort it, and col1 is used as > secondary sort, the result being: > > col1 col2 > A 1 > B 1 > A 2 > B 2 > C 2 > A 5 > A 8 > B 8 > C 8 >
