Table of Contents

Filter Controls

TTMSFNCFilterView ships with purpose-built wrapper controls that each handle the wiring between a UI widget and the underlying filter expression automatically. Drop one into a TTMSFNCFilterView (or add it programmatically), configure DefaultFilterProperties, and the filter text updates as the user interacts with the control.

Note

Set the parent of a filter control after configuring its properties. Assigning Parent triggers creation of the filter structure item. Expressions added before the parent assignment may be overridden on the first structure sync.


CheckBox

TTMSFNCFilterViewCheckBox wraps a standard checkbox. By default it inserts a True expression when checked and nothing when unchecked.

Use custom expressions to override this — for example, to filter out a value when unchecked:

uses
  FMX.TMSFNCFilterView, TMS.TMSFNCFilterBuilder;

// Checkbox with custom expressions — unchecked includes a filter value,
// checked suppresses it (inverse of the default boolean behaviour)
procedure TFormFilterView.AddCheckBox;
var
  filterCheckBox: TTMSFNCFilterViewCheckBox;
begin
  filterCheckBox := TTMSFNCFilterViewCheckBox.Create(FilterView);

  filterCheckBox.DefaultFilterProperties.FilterFieldName := 'Role';
  filterCheckBox.DefaultFilterProperties.FilterFieldType := fdtText;
  filterCheckBox.DefaultFilterProperties.ExpressionOperator := feoEqual;

  // Setting Parent creates the underlying filter structure item
  filterCheckBox.Parent := FilterView;

  filterCheckBox.FilterExpressions.Clear; // remove the default boolean True expression

  // Checked = 'True' in property value: do NOT add to filter
  filterCheckBox.FilterExpressions.AddOrUpdateExpression('True', feoNotEqual, 'Admin', False);
  // Unchecked = 'False': add Role <> 'Admin' to filter
  filterCheckBox.FilterExpressions.AddOrUpdateExpression('False', 'Admin');
end;

Key properties:

Property Description
DefaultFilterProperties Applied when no matching expression is found for the current state.
FilterExpressions Overrides the default per checkbox state (True / False).

Event:

Event Description
OnSetFilterItem Raised before writing to the filter structure; lets you override field name, type, or operator.

RadioButton

TTMSFNCFilterViewRadioButton works identically to the checkbox but is styled as a radio button. Use the GroupName property to make several radio buttons mutually exclusive.


CheckGroup

TTMSFNCFilterViewCheckGroup presents a list of checkboxes generated from its Items property. Each item can have its own expression, or fall back to DefaultFilterProperties.

Key properties:

Property Description
DefaultFilterProperties Default field name, type, and operator for items without a custom expression.
FilterExpressions Per-item expressions keyed by item text (or index when UseCheckBoxTextForPropertyValue is False).
GroupOperator fgoAnd or fgoOr — how multiple checked items are combined in the filter text.
UseCheckBoxTextForPropertyValue When True (default) the item text is used as PropertyValue; set to False to use the item index instead.

Set up a check group that filters a Category field with an OR between checked values:

FilterViewCheckGroup1.Items.Add.Text := 'Electronics';
FilterViewCheckGroup1.Items.Add.Text := 'Clothing';
FilterViewCheckGroup1.Items.Add.Text := 'Food';
FilterViewCheckGroup1.DefaultFilterProperties.FilterFieldName := 'Category';
FilterViewCheckGroup1.DefaultFilterProperties.FilterFieldType := fdtText;
FilterViewCheckGroup1.DefaultFilterProperties.ExpressionOperator := feoEqual;
FilterViewCheckGroup1.GroupOperator := fgoOr;
FilterViewCheckGroup1.Parent := FilterView1;

RadioGroup

TTMSFNCFilterViewRadioGroup displays a list of radio buttons for exclusive-option filtering. Selecting an item activates its expression; all others are cleared.

uses
  FMX.TMSFNCFilterView, TMS.TMSFNCFilterBuilder;

procedure TFormFilterView.AddRadioGroup;
var
  filterRadioGroup: TTMSFNCFilterViewRadioGroup;
begin
  filterRadioGroup := TTMSFNCFilterViewRadioGroup.Create(FilterView);

  // DefaultFilterProperties apply when no matching expression is found
  filterRadioGroup.DefaultFilterProperties.FilterFieldName := 'Delivery';
  filterRadioGroup.DefaultFilterProperties.FilterFieldType := fdtText;
  filterRadioGroup.DefaultFilterProperties.ExpressionOperator := feoEqual;

  filterRadioGroup.Items.AddStrings(['Pick-up store', 'TMS Post', 'Fast Transport', 'Pack AG ING']);

  // Setting Parent triggers creation of the filter structure item
  filterRadioGroup.Parent := FilterView;

  // 'Pick-up store' means no filter — exclude it from the filter text
  filterRadioGroup.FilterExpressions.AddOrUpdateExpression('Pick-up store', '', False);
  filterRadioGroup.ItemIndex := 0;
end;

Key properties:

Property Description
DefaultFilterProperties Used for items with no explicit expression.
FilterExpressions Per-item expressions. Add an expression with AddToFilter = False to make one item act as a "no filter" option.
UseRadioTextForPropertyValue When True (default) the radio text drives expression lookup; set to False to use the item index.

TrackBar

TTMSFNCFilterViewTrackBar maps each slider position to a filter expression. When FilterExpressions is empty the raw numeric value is used directly.

uses
  FMX.TMSFNCFilterView, TMS.TMSFNCFilterBuilder;

procedure TFormFilterView.AddTrackBar;
var
  filterTrackBar: TTMSFNCFilterViewTrackBar;
begin
  filterTrackBar := TTMSFNCFilterViewTrackBar.Create(FilterView);

  filterTrackBar.Min := 0;
  filterTrackBar.Max := 5;

  // DefaultFilterProperties apply for values not in FilterExpressions
  filterTrackBar.DefaultFilterProperties.FilterFieldName := 'VidQuality';
  filterTrackBar.DefaultFilterProperties.FilterFieldType := fdtText;
  filterTrackBar.DefaultFilterProperties.ExpressionOperator := feoEqual;

  filterTrackBar.Parent := FilterView;

  filterTrackBar.BeginUpdate;

  // Map each tick position to a display label and filter value
  filterTrackBar.FilterExpressions.AddOrUpdateExpression('0', 'All', False); // no filter at 0
  filterTrackBar.FilterExpressions.AddOrUpdateExpression('1', '1440p', True);
  filterTrackBar.FilterExpressions.AddOrUpdateExpression('2', '1080p', True);
  filterTrackBar.FilterExpressions.AddOrUpdateExpression('3', '720p', True);
  filterTrackBar.FilterExpressions.AddOrUpdateExpression('4', '480p', True);
  filterTrackBar.FilterExpressions.AddOrUpdateExpression('5', 'Custom', True);

  filterTrackBar.Value := 1;

  filterTrackBar.EndUpdate;
end;

Key properties:

Property Description
DefaultFilterProperties.FilterFieldName Field name applied when no expression matches the current value.
DefaultFilterProperties.FilterFieldType Data type (fdtNumber, fdtText, …).
DefaultFilterProperties.ExpressionOperator Comparison operator (e.g. feoLargerThanOrEqual).
FilterExpressions Optional per-position overrides. Use AddToFilter = False for a "no filter" position at Min.
Note

Use AddOrUpdateExpression(position, filterValueText, addToFilter) where position is the slider value as a string.


RangeSlider

TTMSFNCFilterViewRangeSlider has two thumbs. The left thumb generates one expression (typically >=) and the right thumb generates another (typically <=), producing a range filter automatically.

uses
  FMX.TMSFNCFilterView, TMS.TMSFNCFilterBuilder, System.SysUtils;

// Quick setup using SetDefaultFilterProperties and CreateExpressionsForValues
procedure TFormFilterView.AddRangeSliderQuick;
var
  filterRangeSlider: TTMSFNCFilterViewRangeSlider;
  sl: TStringList;
begin
  filterRangeSlider := TTMSFNCFilterViewRangeSlider.Create(FilterView);

  filterRangeSlider.BeginUpdate;

  filterRangeSlider.Parent := FilterView;
  filterRangeSlider.Min := 0;
  filterRangeSlider.Max := 6;

  // Configure both thumbs at once
  filterRangeSlider.SetDefaultFilterProperties(
    'Date', fdtDateTime, feoLargerThanOrEqual, feoSmallerThanOrEqual);

  // Build the label list: each entry maps to one slider position
  sl := TStringList.Create;
  try
    sl.Add(DateToStr(EncodeDate(1970, 1, 1), FormatSettings));
    sl.Add(DateToStr(EncodeDate(1980, 1, 1), FormatSettings));
    sl.Add(DateToStr(EncodeDate(1990, 1, 1), FormatSettings));
    sl.Add(DateToStr(EncodeDate(2000, 1, 1), FormatSettings));
    sl.Add(DateToStr(EncodeDate(2010, 1, 1), FormatSettings));
    sl.Add(DateToStr(EncodeDate(2020, 1, 1), FormatSettings));
    sl.Add(DateToStr(EncodeDate(2030, 1, 1), FormatSettings));

    // Populates both LeftFilterExpressions and RightFilterExpressions
    filterRangeSlider.CreateExpressionsForValues(sl);
  finally
    sl.Free;
  end;

  filterRangeSlider.EndUpdate;
end;

// Manual setup — configure each thumb independently
procedure TFormFilterView.AddRangeSliderManual;
var
  filterRangeSlider: TTMSFNCFilterViewRangeSlider;
begin
  filterRangeSlider := TTMSFNCFilterViewRangeSlider.Create(FilterView);

  filterRangeSlider.BeginUpdate;

  filterRangeSlider.Parent := FilterView;
  filterRangeSlider.Min := 0;
  filterRangeSlider.Max := 200;

  filterRangeSlider.LeftDefaultFilterProperties.FilterFieldName := 'Price';
  filterRangeSlider.LeftDefaultFilterProperties.FilterFieldType := fdtNumber;
  filterRangeSlider.LeftDefaultFilterProperties.ExpressionOperator := feoLargerThanOrEqual;

  filterRangeSlider.RightDefaultFilterProperties.FilterFieldName := 'Price';
  filterRangeSlider.RightDefaultFilterProperties.FilterFieldType := fdtNumber;
  filterRangeSlider.RightDefaultFilterProperties.ExpressionOperator := feoSmallerThanOrEqual;

  filterRangeSlider.EndUpdate;
end;

Key properties:

Property Description
LeftDefaultFilterProperties Default field, type, and operator for the left (lower) thumb.
RightDefaultFilterProperties Default field, type, and operator for the right (upper) thumb.
LeftFilterExpressions Optional per-position overrides for the left thumb.
RightFilterExpressions Optional per-position overrides for the right thumb.
GroupOperator Logical operator combining the two expressions (default fgoAnd).

Convenience methods:

Method Description
SetDefaultFilterProperties(field, type, leftOp, rightOp) Configures both thumbs in one call.
CreateExpressionsForValues(sl) Populates both LeftFilterExpressions and RightFilterExpressions from a string list, where each entry maps to a slider position.

ComboBox

TTMSFNCFilterViewComboBox filters on the currently selected item. By default the item text becomes the filter value.

uses
  FMX.TMSFNCFilterView, TMS.TMSFNCFilterBuilder;

procedure TFormFilterView.AddComboBox;
var
  filterComboBox: TTMSFNCFilterViewComboBox;
begin
  filterComboBox := TTMSFNCFilterViewComboBox.Create(FilterView);

  filterComboBox.DefaultFilterProperties.FilterFieldName := 'AREA';
  filterComboBox.DefaultFilterProperties.FilterFieldType := fdtText;
  filterComboBox.DefaultFilterProperties.ExpressionOperator := feoEqual;

  filterComboBox.Items.AddStrings(
    ['Africa', 'Antarctica', 'Asia', 'Europe', 'Oceania', 'North-America', 'South-America']);

  filterComboBox.ItemIndex := 0;

  filterComboBox.Parent := FilterView;
end;

Key properties:

Property Description
DefaultFilterProperties Field name, type, and operator for items with no custom expression.
FilterExpressions Per-item overrides. Add an AddToFilter = False expression for an "all" option.
UseItemTextForPropertyValue When True (default) the item text drives expression lookup; False uses the item index.

DatePicker

TTMSFNCFilterViewDatePicker is a date/time control whose selected date is automatically formatted as a filter value using the fdtDate or fdtDateTime field type.

Key properties:

Property Description
DefaultFilterProperties Typically set to fdtDate or fdtDateTime with feoEqual, feoLargerThanOrEqual, etc.
FilterExpressions Optional per-date overrides.

Panel (grouping)

TTMSFNCFilterViewPanel groups child controls under a single logical AND/OR node in the filter structure. It exposes the same Add* methods as TTMSFNCFilterView itself.

var
  panel: TTMSFNCFilterViewPanel;
begin
  panel := FilterView.AddFilterPanel;
  panel.GroupOperator := fgoAnd;
  panel.AddFilterComboBox('Category', fdtText, feoEqual);
  panel.AddFilterComboBox('SubCategory', fdtText, feoEqual);
end;

Key property:

Property Description
GroupOperator fgoAnd or fgoOr — how expressions from child controls are combined.

ExpressionValueEdit

TTMSFNCFilterViewExpressionValueEdit combines a ComboBox (operator selector) and an Edit (value entry) in one control, similar to the expression editor in data grid filter dialogs. Users can choose any operator and type a value directly.

Key properties:

Property Description
UILanguage Textual labels shown for each operator in the dropdown.
FilterExpression The single expression updated as the user changes the operator or value.

Combining a CheckGroup, RangeSlider, and Panel grouping

Use a panel to combine a category check group with a price range slider under a single AND node:

procedure TForm1.FormCreate(Sender: TObject);
var
  panel: TTMSFNCFilterViewPanel;
begin
  panel := FilterView1.AddFilterPanel;
  panel.GroupOperator := fgoAnd;

  FilterViewCheckGroup1.Items.Add.Text := 'Electronics';
  FilterViewCheckGroup1.Items.Add.Text := 'Clothing';
  FilterViewCheckGroup1.DefaultFilterProperties.FilterFieldName    := 'Category';
  FilterViewCheckGroup1.DefaultFilterProperties.FilterFieldType    := fdtText;
  FilterViewCheckGroup1.DefaultFilterProperties.ExpressionOperator := feoEqual;
  FilterViewCheckGroup1.GroupOperator := fgoOr;
  FilterViewCheckGroup1.Parent := panel;

  FilterViewRangeSlider1.SetDefaultFilterProperties('Price', fdtNumber,
    feoLargerThanOrEqual, feoSmallerThanOrEqual);
  FilterViewRangeSlider1.Parent := panel;
end;

Combining multiple control types with an expression event

The previous combination focused on grouping two controls under a panel. The full example below combines a range slider, combo box, and track bar inside a grouped panel and adds an expression handler that surfaces the live filter string:

uses
  FMX.TMSFNCFilterView, TMS.TMSFNCFilterBuilder, System.SysUtils;

// Combined example: multiple control types, grouped panel, expression event,
// and live filter display — shows FilterView features working together.
procedure TFilterViewForm.BuildProductFilter;
var
  fv: TTMSFNCFilterView;
  panel: TTMSFNCFilterViewPanel;
  priceSlider: TTMSFNCFilterViewRangeSlider;
  regionCombo: TTMSFNCFilterViewComboBox;
  ratingBar: TTMSFNCFilterViewTrackBar;
begin
  fv := TTMSFNCFilterView.Create(Self);
  fv.Parent := Self;
  fv.Align := TAlignLayout.Left;
  fv.FilterFormatType := fftDelphiDataSet;
  fv.OnFilterTextChanged := DoFilterTextChanged;
  fv.OnFilterViewItemParse := DoFilterViewItemParse;

  fv.BeginUpdate;

  // --- Availability ---
  fv.AddText('Availability:');
  fv.AddFilterCheckBox(False, 'InStock', fdtBoolean, feoEqual, True).Text := 'In stock';

  // --- Region — combo box ---
  fv.AddText('Region:');
  regionCombo := fv.AddFilterComboBox('AREA', fdtText, feoEqual);
  regionCombo.Items.AddStrings(['(All)', 'Europe', 'Asia', 'Americas']);
  regionCombo.FilterExpressions.AddOrUpdateExpression('(All)', '', False);
  regionCombo.ItemIndex := 0;

  // --- Rating — trackbar ---
  fv.AddText('Min. rating:');
  ratingBar := fv.AddFilterTrackBar(0, 0, 5, 'Rating', fdtNumber, feoLargerThanOrEqual);
  ratingBar.FilterExpressions.AddOrUpdateExpression('0', 'All', False);

  // --- Price — range slider grouped in a panel ---
  fv.AddText('Price range:');
  panel := fv.AddFilterPanel;
  panel.GroupOperator := fgoAnd;
  priceSlider := panel.AddFilterRangeSlider(0, 1000, 0, 1000, 'Price', fdtNumber);
  priceSlider.LeftDefaultFilterProperties.ExpressionOperator := feoLargerThanOrEqual;
  priceSlider.RightDefaultFilterProperties.ExpressionOperator := feoSmallerThanOrEqual;

  fv.EndUpdate;
end;

procedure TFilterViewForm.DoFilterTextChanged(Sender: TObject; AFilterText: string);
begin
  FilterLabel.Text := AFilterText;
  ApplyFilter(AFilterText);
end;

procedure TFilterViewForm.DoFilterViewItemParse(Sender: TObject;
  AItem: TTMSFNCFilterStructureItem; var AText: string; var ASkip: Boolean);
begin
  // Suppress items that produce an empty value to keep the filter clean
  if AText = '' then
    ASkip := True;
end;

See also