Monday 27 January 2014

DevExpress Grid Modify Date Header Filter

In a DevExpress grid I needed to remove options from the filter that is available from the column header. Because the header related to the date column it put in a load of filter options that I did not require. I managed to do this by creating an OnGetFilterValues event:

MyGridView.Columns[MyGridView.GetColumnByFieldName('MY_DATE_FIELD').Index].OnGetFilterValues := cxGridGetFilterValues;

Then I put the following code in the procedure:

procedure MyFrm.cxGridGetFilterValues(Sender: TcxCustomGridTableItem; AValueList: TcxDataFilterValueList);

    procedure DeleteFilterEntry(AValue: Variant);
    begin
        AValueList.Delete(AValueList.FindItemByKind(fviSpecial,               AValue));
    end;
begin
      DeleteFilterEntry(foYesterday);
      DeleteFilterEntry(foToday);
      DeleteFilterEntry(foTomorrow);

      DeleteFilterEntry(foNext7Days);
      DeleteFilterEntry(foNext14Days);
      DeleteFilterEntry(foNext30Days);
end;

There are more filter options that could be removed, it just a matter of looking at the unit that contains the constants.

No comments:

Post a Comment