We handle this in a couple different fashions...for data already in the
grid, (albeit for an ADG vs. a DG), by setting up a custom sorter.
var sorter:Sort = new Sort();
sorter.compareFunction = sortKitNums;
sorter.fields = new Array();
memberReportData.sort = sorter;
memberReportData.refresh();
In the code above, we instantiate our sorter and then point the
compareFunction to our custom sort function. Then we invoke the sort
against our arrayCollection, refresh, then do a validateNow on our ADG
and poof!
Usually, though, we also sort the data on the server before it ever gets
to our flex layer. We are using a MS-SQL Db and via a ton of stored
procedures, our data sets are ordered as we need them before they are
returned to the flex...this way, we use the horsepower of the server vs.
relying on the host machine. This would be easily done for you as well
if you have a date field as the ORDER BY function of most DB languages
will correctly sort your data by a date field.
HTH,
Adrian
valdhor wrote:
I don't know if this is overly helpful but I normally do my initial
sort on the server (It is much easier for the database to do the sorting).
If you really want to do the sort at Flex end you should sort the
underlying dataprovider using the sort and sortfield classes.
See:
http://blog.flexexamples.com/2007/08/05/sorting-an-arraycollection-using-the-sortfield-and-sort-classes/
<http://blog.flexexamples.com/2007/08/05/sorting-an-arraycollection-using-the-sortfield-and-sort-classes/>
--- In flexcoders@yahoogroups.com
<mailto:flexcoders%40yahoogroups.com>, "sleblang" <sc...@...> wrote:
>
> I am looking to have a datagrid initially sort its data by one of its
> columns, the date column. Is the only way to set an initial sort value
> is by simulating a DataGridEvent.HEADER_RELEASE event? This is the only
> solution I could seem to find
>
(http://www.bealearts.co.uk/blog/2007/06/15/default-sorting-for-a-flex-d\
<http://www.bealearts.co.uk/blog/2007/06/15/default-sorting-for-a-flex-d>>
atagrid/
>
<http://www.bealearts.co.uk/blog/2007/06/15/default-sorting-for-a-flex-d\
<http://www.bealearts.co.uk/blog/2007/06/15/default-sorting-for-a-flex-d>>
atagrid/> ) .
>
> Thanks for any and all replies.
>