vcl-cxfilter-46808325.md
A list of filter conditions combined using a logical operator.
TcxFilterCriteriaItemList = class(
TcxCustomFilterCriteriaItem
)
A filter criteria item list stores a list of filter conditions combined using one logical operator. This list can contain both simple and aggregate filter criteria.
The list below outlines key members of the TcxFilterCriteriaItemList class. These members allow you to manage filter conditions.
AddExpressionItem | AddItemAdd a new simple criterion.AddItemListAdds a new aggregate criterion.BoolOperatorKindSpecifies the logical operator that combines conditions at the current level.ClearClears the filter criteria list.CountReturns the number of filter criteria in the list.CriteriaProvides access to the parent filter criteria manager.ItemsProvides indexed access to all filter criteria in the list.
The code example in this section applies the following filter criteria to CustomerCount and Name data grid columns:
(CustomerCount < 1000) AND ((Name LIKE 'A%') OR (Name LIKE 'Z%'))
uses
cxGridDBDataDefinitions; // Declares the TcxGridDBDataController class
// ...
procedure TMyForm.btnApplyFilterClick(Sender: TObject);
var
ADataController: TcxGridDBDataController;
AItemList: TcxFilterCriteriaItemList;
begin
ADataController := cxDBTableView1.DataController;
ADataController.Filter.BeginUpdate; // Initiates the following batch operation
try
ADataController.Filter.Root.Clear;
ADataController.Filter.Root.AddItem(cxDBTableView1CustomerCount, foLess, 1000, '1000');
AItemList := ADataController.Filter.Root.AddItemList(fboOr);
AItemList.AddItem(cxDBTableView1Name, foLike, 'A%', 'A%');
AItemList.AddItem(cxDBTableView1Name, foLike, 'Z%', 'Z%');
ADataController.Filter.Active := True;
finally
ADataController.Filter.EndUpdate; // Calls EndUpdate regardless of the batch operation's success
end;
end;
#include "cxGridDBDataDefinitions.hpp" // Declares the TcxGridDBDataController Class
// Add the following linker directive to the corresponding CPP source file:
#pragma link "cxGridDBDataDefinitions" // Required to use cxGridDBDataDefinitions.hpp declarations
void __fastcall TMyForm::btnApplyFilterClick(TObject *Sender)
{
TcxGridDBDataController *ADataController = cxDBTableView1->DataController;
TcxFilterCriteriaItemList *AItemList;
ADataController->Filter->BeginUpdate(); // Initiates the following batch operation
try
{
ADataController->Filter->Root->Clear();
ADataController->Filter->Root->AddItem(cxDBTableView1CustomerCount, foLess, 1000, "1000");
AItemList = ADataController->Filter->Root->AddItemList(fboOr);
AItemList->AddItem(cxDBTableView1Name, foLike, "A%", "A%");
AItemList->AddItem(cxDBTableView1Name, foLike, "Z%", "Z%");
ADataController->Filter->Active = true;
}
__finally
{
ADataController->Filter->EndUpdate(); // Calls EndUpdate regardless of the batch operation's success
}
}
The TcxFilterCriteria.Root property references a TcxFilterCriteriaItemList object.
TObject TcxCustomFilterCriteriaItem TcxFilterCriteriaItemList
See Also