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

How to Apply a Filter to a Field

The following code snippet demonstrates how to filter the PivotGridPurchaseDate field which contains date-time values, by two dates: 2/1/2002 and 2/2/2002.

PivotGrid.BeginUpdate;
  with PivotGridPurchaseDate.Filter do
  begin
    with Values do
    begin
      // Clears the field's filter condition.
      Clear;
      // Adds two dates into the filter condition.
      Add(EncodeDate(2002, 2, 1));
      Add(EncodeDate(2002, 2, 2));
    end;
    // Specifies the filter type as inclusive.
    FilterType := ftIncluded;
  end;
  PivotGrid.EndUpdate;

As a result, the pivot grid displays only the records that correspond to the created filter.