About working with RecordSet objects
81
The following example filters a RecordSet object to produce a new RecordSet object with records
that have contact fields that start with a specific letter:
var mySelectionFunction = function(aRecord, letter)
{
return (aRecord.contact.charAt(0) == letter);
}
contact_grid.dataProvider = myRecordSet.filter(mySelectionFunction,
theLetter);
In this example:
•
The
contact_grid
variable represents a ListBox UI component.
•
The
myRecordSet
variable represents a record set that has been retrieved by calling a service
function.
•
The
theLetter
variable represents user input in the Flash application (a single letter).
•
The
mySelectionFunction()
function takes a record and a letter and returns the value
true
if the first letter of the record matches the specified letter.
•
The
myRecordSet.filter()
method filters the
myRecordSet
object using the
mySelectionFunction()
function to create a new RecordSet object. Only those records for
which the
mySelectionFunction()
function returns
true
are included in the new RecordSet
object.
•
The Contact_grid component’s
dataProvider
property receives a filtered copy of
myRecordSet object, generated by the
myRecordset.filter()
method, as the data for the
contact_grid
ListBox.
Note:
For RecordSet objects that have 2,000 or fewer records, the
filter()
method generally takes
less than one second to finish. The length of time to filter RecordSet objects increases rapidly as the
number of records grows.
Delivering RecordSet data to Flash applications in ColdFusion MX
By default, Flash Remoting returns a RecordSet object to the Flash client in a single response
when the application server finishes retrieving the data.
In ColdFusion MX, if you expect to return a large record set and the available data transmission
speeds are slow, such as when using dial-up modem, you can choose to return a record set from
the application server in increments. Incremental record sets are also known as
pageable record sets
.
When you use pageable record sets, the following events occur:
•
On the server, the record set is held in session data, and server-side Flash Remoting RecordSet
service provides access to the records.
•
On the client, the RecordSet object can download records when needed by the Flash
application.