HOME PAGE | DOWNLOAD | TUTORIALS | XtraReports
Devexpress

Sunday, July 22, 2012

How to: Perform Custom Filtering When the (Custom) Item is Selected in the Filter Dropdown

The following sample code implements custom filtering and disables the Custom Filter Dialog dialog for the UnitPrice column.

When a (Custom) item is selected in the filter dropdown a custom filter criteria will be created and applied to the View. These criteria select records which contain values less than 10 or greater than 30 in the "UnitPrice" column.

C#

using DevExpress.XtraGrid.Views.Grid;

using DevExpress.XtraGrid.Columns;

 

private void gridView1_CustomFilterDialog(object sender, CustomFilterDialogEventArgs e) {

      if (e.Column.FieldName == "UnitPrice") {

         e.FilterInfo = new ColumnFilterInfo(

           ColumnFilterType.Custom, null, "[UnitPrice] < 10 Or [UnitPrice] > 30",

           "[Unit Price] < '10' Or [Unit Price] > '30'");

         e.Handled = true;

      }

}

 

VB

Imports DevExpress.XtraGrid.Views.Grid
Imports DevExpress.XtraGrid.Columns
 
Private Sub GridView1_CustomFilterDialog(ByVal sender As System.Object, _
  ByVal e As CustomFilterDialogEventArgs) Handles GridView1.CustomFilterDialog
      If e.Column.FieldName = "UnitPrice" Then
         e.FilterInfo = New ColumnFilterInfo( _
           ColumnFilterType.Custom, Nothing, "[UnitPrice] < 10 Or [UnitPrice] > 30", _
           "[Unit Price] < '10' Or [Unit Price] > '30'")
         e.Handled = True
      End If
End Sub

 

No comments:

Post a Comment