Skip to main content
Tab

ASPxFilterControlBase.OperationVisibility Event

Enables you to hide/show the operations for filterable properties within the control.

Namespace: DevExpress.Web

Assembly: DevExpress.Web.v24.1.dll

NuGet Package: DevExpress.Web

Declaration

public event FilterControlOperationVisibilityEventHandler OperationVisibility

Event Data

The OperationVisibility event's data class is FilterControlOperationVisibilityEventArgs. The following properties provide information specific to this event:

Property Description
CustomFunctionName Gets a custom filter function name.
FunctionType Gets a function-based comparison operator type.
Operation Gets the comparison operator type.
PropertyInfo Gets the filterable property of the filter expression.
Visible Gets or sets a value specifying whether the filter operation is visible.

Remarks

The OperationVisibility event is raised for each comparison operator, and allows you to dynamically control its visibility.

The event parameter’s FilterControlOperationVisibilityEventArgs.PropertyInfo and the FilterControlOperationVisibilityEventArgs.Operation properties identify the filterable property (the column being filtered) and its operations. To specify the operator’s visibility, use the FilterControlOperationVisibilityEventArgs.Visible property.

Example

You can hide filter operation items (Contains, Equals, etc.). In the OperationVisibility event handler, a database field name is analyzed, and based on custom conditions, unnecessary operations are hidden.

<dx:ASPxFilterControl ID="filter" runat="server" ClientInstanceName="filter" OnOperationVisibility="filter_FilterOperationVisibility">
    <Columns>
        <dx:FilterControlSpinEditColumn PropertyName="CategoryID" />
        <dx:FilterControlTextColumn PropertyName="CategoryName" />
        <dx:FilterControlTextColumn PropertyName="Description" />
    </Columns>
    <ClientSideEvents Applied="function(s, e) { grid.ApplyFilter(e.filterExpression);}" />
</dx:ASPxFilterControl>
...
<dx:ASPxButton runat="server" ID="btnApply" Text="Apply" AutoPostBack="false" UseSubmitBehavior="false">
    <ClientSideEvents Click="function() { filter.Apply(); }" />
</dx:ASPxButton>
...
<dx:ASPxGridView ID="grid" ClientInstanceName="grid" runat="server" DataSourceID="AccessDataSource1"
    KeyFieldName="CategoryID" Width="100%" AutoGenerateColumns="False">
    <Columns>
        <dx:GridViewDataTextColumn FieldName="CategoryID" VisibleIndex="0" />
        <dx:GridViewDataTextColumn FieldName="CategoryName" VisibleIndex="1" />
        <dx:GridViewDataTextColumn FieldName="Description" VisibleIndex="2" />
    </Columns>
</dx:ASPxGridView>

<asp:AccessDataSource ID="AccessDataSource1" runat="server" DataFile="~/App_Data/nwind.mdb"
    SelectCommand="SELECT * FROM [Categories]" />
using DevExpress.Data.Filtering.Helpers;
using DevExpress.Web.ASPxEditors;


public partial class _Default : System.Web.UI.Page {
    static List<ClauseType> AllowedOperations {
        get {
            return new List<ClauseType>(new ClauseType[6]{ 
                    ClauseType.Equals, ClauseType.DoesNotEqual,
                    ClauseType.BeginsWith, ClauseType.EndsWith,
                    ClauseType.Contains, ClauseType.DoesNotContain
                });
        }
    }
    protected void Page_Load(object sender, EventArgs e) {
        if(!IsPostBack) {
            filter.FilterExpression = grid.FilterExpression = "[CategoryName] Like '%ns%'";
        }
    }
    protected void filter_FilterOperationVisibility(object sender, FilterControlOperationVisibilityEventArgs e) {
        if(e.PropertyInfo.PropertyName == "CategoryName" || e.PropertyInfo.PropertyName == "Description") {
            e.Visible = AllowedOperations.Contains(e.Operation);
        }
    }
}
See Also