User Guide

DataSet component (Flash Professional only) 319
Example
In the following example, filtering is enabled on the DataSet object named employee_ds.
Suppose that each record in the DataSet collection contains a field named
empType. The
following filter function returns
true if the empType field in the current item is set to
"management"; otherwise, it returns false.
employee_ds.filtered = true;
employee_ds.filterFunc = function(item:Object) {
// filter out employees who are managers...
return(item.empType != "management");
}
See also
DataSet.filterFunc
DataSet.filterFunc
Availability
Flash Player 7.
Edition
Flash MX Professional 2004.
Usage
dataSet.filterFunc = function(item:Object) {
// return true|false;
};
Description
Property; specifies a function that determines which items are included in the current view of the
collection. When
DataSet.filtered is set to true, the function assigned to this property is
called for each record (transfer object) in the collection. For each item that is passed to the
function, it should return
true if the item should be included in the current view, or false if the
item should not be included in the current view.
When changing the filter function on a data set, you must set the
filtered property to false
and then
true again in order for the proper modelChanged event to be generated. Changing the
filterFunc property wont generate the event.
Also, if a filter is already in place when the data loads in (
modelChanged or updateAll), the filter
isnt applied until
filtered is set to false and then back to true again.
Example
In the following example, filtering is enabled on the DataSet object named employee_ds. The
specified filter function returns
true if the empType field in each item is set to "management";
otherwise, it returns
false.
employee_ds.filtered = true;
employee_ds.filterFunc = function(item:Object) {
// filter out employees who are managers...