Skip to main content

Example: TcxFilterCriteriaItemList.AddItem, TcxFilterCriteriaItemList.AddItemList, TcxFilterCriteria.Root, TcxFilterCriteria.BeginUpdate, TcxFilterCriteria.EndUpdate

The following example demonstrates how to set filter criteria for the following string:

(CustNo < 1000) AND ((Name LIKE ‘A%’) OR (Name LIKE ‘Z%’)).

The DBTableView1CustNo and DBTableView1Name objects are of the TcxGridDBColumn class. They identify the desired items in a grid control.

To prevent filter criteria from being updated every time a filter condition is added, operations are enclosed within the TcxFilterCriteria.BeginUpdate and TcxFilterCriteria.EndUpdate methods.

var
  AItemList: TcxFilterCriteriaItemList;
//...
  FDataController.Filter.BeginUpdate;
  try
    FDataController.Filter.Root.Clear;
    FDataController.Filter.Root.AddItem(DBTableView1CustNo, foLess, 1000, '1000');
    AItemList := FDataController.Filter.Root.AddItemList(fboOr);
    AItemList.AddItem(DBTableView1Name, foLike, 'A%', 'A%');
    AItemList.AddItem(DBTableView1Name, foLike, 'Z%', 'Z%');
  finally
    FDataController.Filter.EndUpdate;
  end;