Description:
I do not use the Filter.AutoDataSetFilter property of the Data Controller because the filter expressions the Data Controller produces cannot be applied to my datasets. However, I need the Grid's underlying dataset to be filtered as well when a user filters the Grid's records and thus, I use the Data Controller's Filter.OnBeforeChange event as described in your article "Why is the underlying dataset not correctly filtered when a filter is applied to the View records?".
This works OK, but temporary deactivating of the filter (only deactivating, not removing) fails because within the event handler I do not know that the filter is deactivated. How to overcome this?
Answer:
The Filter.OnBeforeChange and Filter.OnChanged events are fired when the filter is (de)activated. You should just verify the Filter.Active property value to determine whether the filter is applied or not.
Delphiprocedure TYour_Form.AViewDataControllerFilterBeforeChange(
Sender: TcxDBDataFilterCriteria; ADataSet: TDataSet;
const AFilterText: String);
begin
if Sender.DataController.Filter.Active then
// Apply the filter to the dataset
else
// Reset the dataset's filter
end;