The following example shows how you can do a date sort on the Flex FileSystemDataGrid control in Adobe AIR by setting a custom sort compare function on the creationDateColumn and modificationDateColumn objects.

<?xml version="1.0" encoding="utf-8"?>
<!-- -->
<mx:WindowedApplication name="FileSystemDataGrid_creationDateColumn_sortCompareFunction_test"
        width="600" minHeight="400">
            import mx.utils.ObjectUtil;
            private function init():void {
                fsdg.creationDateColumn.sortCompareFunction = createDateSortCompFunc("creationDate");
                fsdg.modificationDateColumn.sortCompareFunction = createDateSortCompFunc("modificationDate");
            private function createDateSortCompFunc(sortCol:String):Function {
                return function (obj1:File, obj2:File):int { 
                    return ObjectUtil.dateCompare(obj1[sortCol], obj2[sortCol]);
    <mx:ApplicationControlBar dock="true"> 
        <mx:Label id="sdkVer" initialize="sdkVer.text = mx_internal::VERSION;" /> 
    <mx:FileSystemDataGrid id="fsdg"
            width="100%" height="100%"
            creationComplete="init();" /> 

2 Responses to Sorting the FileSystemDataGrid control by date in Adobe AIR

  1. jeff says:

    is there a way to keep whatever sort was clicked as user change directories?

  2. jeff says:

    so as they navigate back if they sorted in those directories the sort will remain?

    by default it doesnt keep it

Leave a Reply

Your email address will not be published.

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong> <pre lang="" line="" escaped="" highlight="">

Spam Protection by WP-SpamFree