Ticket A962
Visible to All Users

How to determine if a filter is active when the Filter.OnBeforeChange or Filter.OnChanged event is fired

created 21 years ago (modified 3 months ago)

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.

Delphi
procedure 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;

Disclaimer: The information provided on DevExpress.com and affiliated web properties (including the DevExpress Support Center) is provided "as is" without warranty of any kind. Developer Express Inc disclaims all warranties, either express or implied, including the warranties of merchantability and fitness for a particular purpose. Please refer to the DevExpress.com Website Terms of Use for more information in this regard.

Confidential Information: Developer Express Inc does not wish to receive, will not act to procure, nor will it solicit, confidential or proprietary materials and information from you through the DevExpress Support Center or its web properties. Any and all materials or information divulged during chats, email communications, online discussions, Support Center tickets, or made available to Developer Express Inc in any manner will be deemed NOT to be confidential by Developer Express Inc. Please refer to the DevExpress.com Website Terms of Use for more information in this regard.