YOUSEFUL / DELPHI / COMPONENTS

TAtlasFilterEdit

An edit box that applies its text to a TAtlasDataFilter every time the text changes.

Visual control Palette: Atlas Data Unit Atlas.DBFilter · Inherits TEdit · Product Atlas Info

Description

TAtlasFilterEdit is a TEdit descendant. Set Filter, FieldName and, if you want another mode than contains, Match. Each time the text changes, the edit calls Filter.Apply(FieldName, Text, Match) and then fires its own OnChange, so empty text clears the filter. Nothing happens while Filter is nil, FieldName is empty or the form is loading.

Changing FieldName or Match does not filter again; the next text change does. There is no delay: the dataset is refreshed on every keystroke.

The edit does not catch errors from Apply. Typing while the dataset is being edited raises EAtlasDatabaseError (Post or cancel before filtering) through the application's exception handler; the text stays as typed while the dataset keeps its previous filter. All other members, such as TextHint, are the standard TEdit ones.

Members

MemberKindWhat it does
FilterpropertyThe TAtlasDataFilter to drive.
FieldNamepropertyName of the field passed to Apply.
MatchpropertyMatch mode passed to Apply.

Properties

Filter property

property Filter: TAtlasDataFilter read FFilter write SetFilter;

The TAtlasDataFilter to drive. The edit receives a free notification and sets this property to nil when the controller is destroyed.

FieldName property

property FieldName: string read FFieldName write FFieldName;

Name of the field passed to Apply. While it is empty, typing does not filter.

Match property

property Match: TAtlasTextMatch read FMatch write FMatch default atmContains;

Match mode passed to Apply. Default atmContains.

pascal
FilterEdit.Match := atmPrefix;  // names that start with the typed text

Examples

Filter a grid as the user types

Puts a filter box on a panel. Typing SERV in it leaves Harbor Services in the tutorial's customer table; clearing the box shows every customer again.

pascal
uses Vcl.Controls, Atlas.DBFilter;

function AddFilterBox(Parent: TWinControl; Filter: TAtlasDataFilter): TAtlasFilterEdit;
begin
  Result := TAtlasFilterEdit.Create(Parent);
  Result.Parent := Parent;
  Result.Filter := Filter;
  Result.FieldName := 'Name';
  Result.Match := atmContains;
  Result.TextHint := 'Filter customer names';
end;

TAtlasDataFilter · TAtlasTextMatch

Also in Atlas Info

TAtlasDBGrid · TAtlasDBLookupCombo · TAtlasDBRichEdit · TAtlasDataFilter