I don't think you can use the sortCompareFunction that way...it needs a function to process your data against.

We use a number of customized sorting functions on a number of our fields via both sort.compareFunction as well as adg.sortCompareFunction, though funny enough, the compareFunction is a bit different depending on which way you are using it. If you are tying it to an ADG sortCompareFunction, it takes two arguments while when using a Sort() compareFunction, it takes three.

When trying to do an alphabetical sort (on the ADG), we do this:

public static function compareLastNames(name1:Object, name2:Object):int
       {
var newName1:String = name1.LastName + name1.FirstName + name1.MiddleName; var newName2:String = name2.LastName + name2.FirstName + name2.MiddleName; if (newName1.toLowerCase() < newName2.toLowerCase())
           {
               return -1;
           }
           else if (newName1.toLowerCase() > newName2.toLowerCase())
           {
               return 1;
           }
           else
           {
               return 0;
           }
       }

and when using a Sort() we do the very same logic but we have to add a "fields" parameter into the method signature:

public static function compareLastNamesWithFields(name1:Object, name2:Object, fields:Array = null):int

In this case, we've automatically set the fields array to null as we never have any fields to pass in but without it, flex throws errors (we've long thought this to be a bug). Also note that these are public and static because we've abstracted them into a class.
Hope this helps!
Adrian






Jeffry Houser wrote:


Keith Hughitt wrote:
> When working with DataGrid ItemRenderers, you can say something like
> itemrenderer="Text", and Flex will know how to deal with the data.
>

I just tested, this gives me a compiler error both on a ComboBox and
DataGrid.
What are you doing that I'm not doing?

> Is there anyway you can do this with a sortCompareFunction, e.g.
>
> sortCompareFunction="Numeric" or sortCompareFunction="String"?
>

Will using the sortOptions property on a DataGridColumn do what you want?
http://livedocs.adobe.com/flash/9.0/ActionScriptLangRefV3/fl/controls/dataGridClasses/DataGridColumn.html#sortOptions <http://livedocs.adobe.com/flash/9.0/ActionScriptLangRefV3/fl/controls/dataGridClasses/DataGridColumn.html#sortOptions> http://livedocs.adobe.com/flash/9.0/ActionScriptLangRefV3/Array.html#sort <http://livedocs.adobe.com/flash/9.0/ActionScriptLangRefV3/Array.html#sort>()

--
Jeffry Houser, Technical Entrepreneur
Adobe Community Expert: http://tinyurl.com/684b5h <http://tinyurl.com/684b5h> http://www.twitter.com/reboog711 <http://www.twitter.com/reboog711> | Phone: 203-379-0773
--
Easy to use Interface Components for Flex Developers
http://www.flextras.com?c=104 <http://www.flextras.com?c=104>
--
http://www.theflexshow.com <http://www.theflexshow.com>
http://www.jeffryhouser.com <http://www.jeffryhouser.com>
--
Part of the DotComIt Brain Trust


Reply via email to