Sorting record sets
To sort the records of a RecordSet object, use the
method performs an ascending (the default) or descending sort on the records in
sortItemBy()
the RecordSet object. The
and uses that function to sort the records. The
in Flash Player 7.x and is substantially faster than the
Sorting a RecordSet object changes the order of the records in the object, but does not otherwise
change the object. Subsequent calls to the
new order. After you sort a RecordSet object that was returned from an application, the object no
longer reflects the order of the records on the server-side record set.
The following one-line example sorts the myRecordSet object according to the value of the
DepartmentName field in descending order:
myRecordSet.SortItemsBy("DepartmentName", null, Array.DESCENDING);
The following example sorts a record set prior to displaying it in a ListBox UI component:
function onCustData( re:ResultEvent ):Void {
var rs:RecordSet = RecordSet( re.result );
rs.sortItemsBy(["TotalSales","Name"], null, Array.DESCENDING |
Array.NUMERIC);
DataGlue.bindFormatFunction( cust_ListBox, rs, formatSales);
}
In this example,
the
rs.sortItemsBy()
column in descending order.
For an example of using the
Remoting ActionScript Dictionary Help.
Note: For RecordSet objects containing 2,000 or fewer records, the
takes less than one second to finish on a Pentium 3 computer. The length of time to sort RecordSet
objects increases rapidly as the number of records grows.
Filtering an existing RecordSet object to create a new RecordSet object
The
method creates a filtered view of a RecordSet object that contains only records that
filter()
conform to a set of rules specified by a selection (filter) function that you define. Unlike the
method, the
sortItems()
RecordSet object and its records remain unchanged.
The selection function that you define takes a record as the first argument, and can take an
optional second argument to determine how to select the records. The function must return a
Boolean
or
true
which the selection function returns
selection function and, optionally, the value to use as the selection function's second argument.
The
RecordSet.filter()
set.
80
Chapter 4: Using Flash Remoting Data in ActionScript
sortItems()
represents a ListBox UI component in the Flash application. In
cust_ListBox
method, it sorts the records according to the contents of the
sortItems()
method creates a new RecordSet object. The original
filter()
value. Flash Remoting includes in the filtered RecordSet those records for
false
true
method calls the selection function once for each record in the record
and
sortItems
method requires a comparison function as an argument,
sortItemsBy()
sortItems()
method return records according to the
getItemAt()
method, see the RecordSet.sortIems() method in Flash
. When you call the
filter()
methods. The
sortItemBy()
method is implemented natively
method.
TotalSales
method generally
sortItems()
method, you pass it your
Need help?
Do you have a question about the FLASH REMOTING MX-USING FLASH REMOTING FOR FLASH MX 2004 ACTIONSCRIPT 2.0 and is the answer not in the manual?
Questions and answers