Skip to main content

DevExpress v24.2 Update — Your Feedback Matters

Our What's New in v24.2 webpage includes product-specific surveys. Your response to our survey questions will help us measure product satisfaction for features released in this major update and help us refine our plans for our next major release.

Take the survey Not interested

Example: TcxDBDataFilterCriteria.OnBeforeChange

In this example, the TcxDBDataFilterCriteria.OnBeforeChange event is used to change the filter for the object of the query class from which data is retrieved.

The first two rows of the query specify:

SELECT *

FROM ORDERS.DB

In this event, the WHERE clause is added. AFilterText describes a condition to apply.

procedure TForm1.DBTableView1DataControllerFilterBeforeChange(
  Sender: TcxDBDataFilterCriteria; ADataSet: TDataSet;
  const AFilterText: String);
begin
  Query1.DisableControls;
  try
    Query1.Active := False;
    if AFilterText <> '' then
      //add condition to the query
      Query1.SQL[2] := 'WHERE ' + AFilterText;
    else
      Query1.SQL[2] := '';
    Query1.Active := True;
  finally
    Query1.EnableControls;
  end;
end;