Name
RecordSet.filter( ) Method
Synopsis
myRecordSet
.filter(filterFunction
,context
)
Arguments
-
filterFunction
A custom function that acts as a filter for the recordset.
-
context
A parameter that can be passed to the filter function as an argument.
Returns
A filtered RecordSet object.
Description
The filter( ) method creates a second recordset by filtering an existing recordset using a custom filter function. This function can filter the recordset on any kind of criteria you prefer. You could, for example, filter a recordset by date, returning only those records that contain a field that is within a certain date range. You can filter any other criteria, such as length of a field, first letter of a field, or a certain word within a field.
The filtered recordset does not contain any reference or association to the original server-side recordset, such as paging. However, the new RecordSet object created by the filter( ) method contains references to rows in the original client-side Recordset object, not copies of that data. The filter( ) method also consumes memory and processing time, so it should be used sparingly.
The filter function that you define can accept one or two arguments.
The first argument is a record to examine, and the second, optional
argument can be used in your filter criteria. Each record of the
original RecordSet object is passed to the
filter function; if the filter function returns
true
, the record is added to the new, filtered
RecordSet object.
Example
The following code ...
Get Flash Remoting: The Definitive Guide now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.