Filtered Filter Options Filter Group OnFilter Record

The Filtered property is a Boolean value (True or False) that determines if the string in the Filter property is used to filter the dataset. When Filtered is False, the filtering is ignored and the complete dataset is available to the application.

The FilterOptions is a set of two values - both used when filtering string fields. If the foCaseInsensitive is included in the FilterOptions, comparison between the literal in the Filter property string and the field values are case-insensitive. The foNoPartialCompare forces Delphi to treat the asterisks (*) as a literal character rather than as wildcard. By default, FilterOptions is set to an empty set.

The OnFilterRecord event fires each time the filtering is enabled and a new record becomes the current one. You will generally use this event to filter records using a criterion that can't be (easily) implemented using the Filter property.

procedure TForm1.ADOTable1FilterRecord

(DataSet: TDataSet; var Accept: Boolean);

var AppZipSize : Single;

begin

AppZipSize := ADOTable1.FieldByName('size'

.Value;

Accept := (AppZipSize < 10);

end;

The key element here is the Accept parameter. You set the Accept parameter to True for any rows that you want to show. The preceding code sets Accept to True for any rows in which the Size field contains a value that is less than 10 (all apps whose download size is less than 10 Kb).

The FilterGroup set property allows you to filter records depending on their status.

Was this article helpful?

0 0

Post a comment