The SortField objects take the name of the field in the object to be sorted as a String – so your dot _expression_ will not work.

 

What you can do is write a custom compareFunction for your Sort object. A compareFunction takes two objects and returns -1, 0, or 1 depending on which order the two objects should be sorted. The ASDoc for Sort.compareFunction has the function signature and a good example so check that out for more info.

 

Your custom compareFunction can access top-level and sub-properties on each object and then sort accordingly.

 

-deepa

 


From: flexcoders@yahoogroups.com [mailto:[EMAIL PROTECTED] On Behalf Of dreuimar
Sent: Thursday, August 31, 2006 9:44 AM
To: flexcoders@yahoogroups.com
Subject: [flexcoders] Problem with Sorting

 

Hey everyone,

I have an array collection of Industry objects which are all
sub-industries. Each industry object has as a property a parent
industry (of datatype Industry);

Industry VO contains properties:

industryId : int;
parent : Industry;
name : String;

I want to sort the array by the parent industry first, and then the
children industries names.

I was going to do something like:

var sort : Sort = new Sort();
sort.fields = [ new SortField("parent.name", true), new
SortField("name", true) ];

...but this isn't working.

Is there any way of going deeper than just immediate properties for a
sortfield?

Brennan

__._,_.___

--
Flexcoders Mailing List
FAQ: http://groups.yahoo.com/group/flexcoders/files/flexcodersFAQ.txt
Search Archives: http://www.mail-archive.com/flexcoders%40yahoogroups.com





SPONSORED LINKS
Software development tool Software development Software development services
Home design software Software development company


YAHOO! GROUPS LINKS




__,_._,___

Reply via email to