Tab
A newer version of this page is available. Switch to the current version.

ASPxFilterControl Class

Represents a filter control.

Namespace: DevExpress.Web

Assembly: DevExpress.Web.v18.2.dll

Declaration

public class ASPxFilterControl :
    ASPxFilterControlBase,
    IControlDesigner
Public Class ASPxFilterControl
    Inherits ASPxFilterControlBase
    Implements IControlDesigner

Related API Members

The following members accept/return ASPxFilterControl objects:

Remarks

The ASPxFilterControl is a stand-alone control that allows end-users to build filter criteria. It does not require any SQL syntax and doesn't have any limitations regarding filter condition complexity. With the ASPxFilterControl, you can construct any number of filter conditions, combined by any logical operator, and apply them to controls or to a data source.

ASPxFilterControl-1

 

The ASPxFilterControl isn't designed to operate with the bound source control. To enable end-users to construct filter criteria, you should manually create filter columns and add them to the ASPxFilterControl.Columns collection. The ASPxFilterControl provides eight column types (text, spin, combobox columns, etc.). The image below shows how to create filter columns at design time:

FilterColumnsCollection

The example below demonstrates how to create a filter column in code:


private void CreateSpinEditColumn(ASPxFilterControl filterControl, string propertyName, 
    string displayName) {
    FilterControlSpinEditColumn filterColumn = new FilterControlSpinEditColumn();
    filterColumn.PropertyName = propertyName;
    filterColumn.DisplayName = displayName;
    filterControl.Columns.Add(filterColumn);
}

The current filter expression is returned by the ASPxFilterControlBase.FilterExpression property. After the filter expression has been constructed by an end-user, you can apply it to the ASPxFilterControl. To do this, use the ASPxFilterControlBase.ApplyFilter server method, or the ASPxClientFilterControl.Apply client method.

<dx:ASPxButton runat="server" ID="btnApply" Text="Apply" AutoPostBack="false" 
        UseSubmitBehavior="false">
    <ClientSideEvents Click="function() { filter.Apply(); }" />
</dx:ASPxButton>

Once applied, the filter expression can be obtained via the ASPxFilterControlBase.AppliedFilterExpression property. To apply the filter to a control or data source, handle the ASPxClientFilterControl.Applied event.

<dx:ASPxFilterControl ID="filter" runat="server" ClientInstanceName="filter">
    <Columns>
        <dx:FilterControlColumn PropertyName="ProductName"  />
        <dx:FilterControlColumn PropertyName="OrderDate" ColumnType="DateTime"  />
        <dx:FilterControlColumn PropertyName="UnitPrice"  />
    </Columns>
     <ClientSideEvents applied="function(s, e) { grid.ApplyFilter(e.filterExpression); }"/>
</dx:ASPxFilterControl>

To reset the current filter expression to a previously applied filter expression, use the ASPxFilterControlBase.ResetFilter or ASPxClientFilterControl.Reset method. This sets the ASPxFilterControlBase.FilterExpression property to the ASPxFilterControlBase.AppliedFilterExpression property's value.

<dx:ASPxButton runat="server" ID="btnReset" Text="Reset" AutoPostBack="false" 
        UseSubmitBehavior="false">
    <ClientSideEvents Click="function() { filter.Reset(); }" />
</dx:ASPxButton>

 

NOTE

The client-side equivalent of this control is represented by the ASPxClientFilterControl object. The control's client-side API is enabled if the ASPxFilterControl.ClientInstanceName property is defined, or any client event is handled. Available client events can be accessed via the ASPxFilterControl.ClientSideEvents property.

Note that although the ASPxGridView control provides an embedded Filter Control, you can still use a separate ASPxFilterControl, with the ASPxGridView control to provide standalone filter editing.

See Also