Skip to main content
A newer version of this page is available. .

ColumnView.FilterPopupExcelData Event

Allows you to remove and modify items within Excel-style Filter Dropdowns, as well as add your own custom items that apply specific filtering conditions.

Namespace: DevExpress.XtraGrid.Views.Base

Assembly: DevExpress.XtraGrid.v18.1.dll

Declaration

[DXCategory("Behavior")]
public event FilterPopupExcelDataEventHandler FilterPopupExcelData

Event Data

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

Property Description
Column Gets the column being processed. Inherited from ExcelFilteringDataEventArgs<TColumn>.
DataItems Provides access to the collection of data values by which the column being processed can be filtered, and the corresponding display texts. Inherited from ExcelFilteringDataEventArgs.
DisplayTexts Provides acces to the collection of the texts to be displayed in the filter popup for the corresponding data values by which the column being processed can be filtered. Inherited from ExcelFilteringDataEventArgs.
FilterItems Provides access to the collection of custom filter conditions by which the column being processed can be filtered. Inherited from ExcelFilteringDataEventArgs.
HtmlImages Gets or sets a collection of images to be inserted into filter item captions using HTML tags. This property is in effect when the HTML formatting feature is enabled for filter item captions. Inherited from ExcelFilteringDataEventArgs.
IsNotLoaded Gets or sets whether the data is not yet loaded during asynchronous data loading. Inherited from ExcelFilteringDataEventArgs.
Values Provides access to the collection of data values by which the column being processed can be filtered. Inherited from ExcelFilteringDataEventArgs.

The event data class exposes the following methods:

Method Description
AddData(Object, String, Boolean) Adds the specified data value by which the column being processed can be filtered, and the corresponding text to be displayed in the filter popup. Inherited from ExcelFilteringDataEventArgs.
AddFilter(String, CriteriaOperator, Boolean) Adds the specified filter condition by which the column being processed can be filtered, and the corresponding text to be displayed in the filter popup. Inherited from ExcelFilteringDataEventArgs.
AddFilter(String, String, Boolean) Adds the specified filter condition by which the column being processed can be filtered, and the corresponding text to be displayed in the filter popup. Inherited from ExcelFilteringDataEventArgs.
ChangeText(Object, String) Changes the display text in the filter popup for the specified data value. Inherited from ExcelFilteringDataEventArgs.
ClearData() Inherited from ExcelFilteringDataEventArgs.
GetDisplayTexts() Returns an array of strings representing captions for filters in the popup. Inherited from ExcelFilteringDataEventArgs.
GetFilterItems() Returns the collection of custom filter conditions by which the column being processed can be filtered. Inherited from ExcelFilteringDataEventArgs.
GetValues() Returns an array of objects representing data values by which the column being processed can be filtered. Inherited from ExcelFilteringDataEventArgs.
RemoveData(Object) Removes the specified data value by which the column being processed can be filtered from the filter popup. Inherited from ExcelFilteringDataEventArgs.

Remarks

The code snippet below shows how to handle the FilterPopupExcelData event to add custom filters for particular columns.


void gridView_FilterPopupExcelData(object sender, FilterPopupExcelDataEventArgs e) {
    string fieldName = e.Column.FieldName;
    if(e.Column == bcModification) {
        e.AddFilter("<image=A><nbsp>Automatic Transmission (6-speed)", "Contains([" + fieldName + "], '6A')", true);
        e.AddFilter("<image=A><nbsp>Automatic Transmission (8-speed)", "Contains([" + fieldName + "], '8A')", true);
        e.AddFilter("<image=M><nbsp>Manual Transmission (6-speed)", "Contains([" + fieldName + "], '6M')", true);
        e.AddFilter("<image=M><nbsp>Manual Transmission (7-speed)", "Contains([" + fieldName + "], '7M')", true);
        e.AddFilter("<image=V><nbsp>Variadic Transmission", "Contains([" + fieldName + "], 'VA')", true);
        e.AddFilter("<b>Limited Edition</b>", "Contains([" + fieldName + "], 'Limited')", true);
    }
    if(e.Column == bcMPGCity) {
        e.AddFilter("Fuel Economy (<color=green>High</color>)", "[" + fieldName + "]<=15", true);
        e.AddFilter("Fuel Economy (<color=orange>Medium</color>)", "[" + fieldName + "]>15 AND [" + fieldName + "]<25", true);
        e.AddFilter("Fuel Economy (<color=red>Low</color>)", "[" + fieldName + "]>=25", true);
    }
}

See the result below.

ColumnView_FilterPopupExcelData

See Also