DataControlBase.ClearColumnFilter(ColumnBase) Method
Removes the filter condition applied to the specified column.
Namespace: DevExpress.Xpf.Grid
Assembly: DevExpress.Xpf.Grid.v18.2.Core.dll
Declaration
public void ClearColumnFilter(
ColumnBase column
)
Public Sub ClearColumnFilter(
column As ColumnBase
)
Parameters
Name |
Type |
Description |
column |
ColumnBase |
A ColumnBase descendant that represents the column whose filter is cleared.
|
To clear the grid’s filter, set the DataControlBase.FilterCriteria property to null or the DataControlBase.FilterString property to an empty string.
To learn more, see Regular and Checked Drop-down Filters.
Example
This example shows how to replace the Date column’s drop-down filter items with custom items:
- (All) - Cancels filtering
- Registered in 2008 - Shows users that were registered in 2008
- Registered in 2009 - Shows users that were registered in 2009
The image below shows the result:
<Window x:Class="DXGrid_CustomizingFilterDropdown.Window1"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:dxg="http://schemas.devexpress.com/winfx/2008/xaml/grid"
Title="Window1" Height="300" Width="535">
<Grid>
<dxg:GridControl x:Name="grid" ItemsSource="{Binding AccountList}">
<dxg:GridControl.Columns>
<dxg:GridColumn FieldName="UserName"/>
<dxg:GridColumn FieldName="RegistrationDate" FilterPopupMode="List"/>
</dxg:GridControl.Columns>
<dxg:GridControl.View>
<dxg:TableView AutoWidth="True" ShowFilterPopup="TableView_ShowFilterPopup" />
</dxg:GridControl.View>
</dxg:GridControl>
</Grid>
</Window>
using System;
using System.Collections.Generic;
using System.Windows;
using System.Windows.Documents;
using DevExpress.Data.Filtering;
using DevExpress.Xpf.Grid;
namespace DXGrid_CustomizingFilterDropdown {
public partial class Window1 : Window {
public Window1() {
InitializeComponent();
this.DataContext = new MyViewModel();
}
private void TableView_ShowFilterPopup(object sender, FilterPopupEventArgs e) {
if (e.Column.FieldName != "RegistrationDate") return;
List<object> filterItems = new List<object>();
filterItems.Add(new CustomComboBoxItem()
{
DisplayValue = "(All)",
EditValue = new CustomComboBoxItem()
});
filterItems.Add(new CustomComboBoxItem()
{
DisplayValue = "Registered in 2008",
EditValue = CriteriaOperator.Parse(string.Format(
"[RegistrationDate] >= #{0}# AND [RegistrationDate] < #{1}#",
new DateTime(2008, 1, 1), new DateTime(2009, 1, 1)))
});
filterItems.Add(new CustomComboBoxItem()
{
DisplayValue = "Registered in 2009",
EditValue = CriteriaOperator.Parse(string.Format(
"[RegistrationDate] >= #{0}# AND [RegistrationDate] < #{1}#",
new DateTime(2009, 1, 1), new DateTime(2010, 1, 1)))
});
e.ComboBoxEdit.ItemsSource = filterItems;
}
}
public class MyViewModel {
public MyViewModel() {
AccountList = CreateAccounts();
}
public List<Account> AccountList { get; set; }
private List<Account> CreateAccounts() {
List<Account> list = new List<Account>();
list.Add(new Account() {
UserName = "Nick White",
RegistrationDate = DateTime.Today
});
list.Add(new Account() {
UserName = "Jack Rodman",
RegistrationDate = new DateTime(2009, 5, 10)
});
list.Add(new Account() {
UserName = "Sandra Sherry",
RegistrationDate = new DateTime(2008, 12, 22)
});
list.Add(new Account() {
UserName = "Sabrina Vilk",
RegistrationDate = DateTime.Today
});
list.Add(new Account() {
UserName = "Mike Pearson",
RegistrationDate = new DateTime(2008, 10, 18)
});
return list;
}
}
public class Account {
public string UserName { get; set; }
public DateTime RegistrationDate { get; set; }
}
}
Imports System
Imports System.Collections.Generic
Imports System.Windows
Imports System.Windows.Documents
Imports DevExpress.Data.Filtering
Imports DevExpress.Xpf.Grid
Namespace DXGrid_CustomizingFilterDropdown
Partial Public Class Window1
Inherits Window
Public Sub New()
InitializeComponent()
Me.DataContext = New MyViewModel()
End Sub
Private Sub TableView_ShowFilterPopup(ByVal sender As Object, ByVal e As FilterPopupEventArgs)
If e.Column.FieldName <> "RegistrationDate" Then
Return
End If
Dim filterItems As New List(Of Object)()
filterItems.Add(New CustomComboBoxItem() With {.DisplayValue = "(All)", .EditValue = New CustomComboBoxItem()})
filterItems.Add(New CustomComboBoxItem() With {.DisplayValue = "Registered in 2008", .EditValue = CriteriaOperator.Parse(String.Format("[RegistrationDate] >= #{0}# AND [RegistrationDate] < #{1}#", New Date(2008, 1, 1), New Date(2009, 1, 1)))})
filterItems.Add(New CustomComboBoxItem() With {.DisplayValue = "Registered in 2009", .EditValue = CriteriaOperator.Parse(String.Format("[RegistrationDate] >= #{0}# AND [RegistrationDate] < #{1}#", New Date(2009, 1, 1), New Date(2010, 1, 1)))})
e.ComboBoxEdit.ItemsSource = filterItems
End Sub
End Class
Public Class MyViewModel
Public Sub New()
AccountList = CreateAccounts()
End Sub
Public Property AccountList() As List(Of Account)
Private Function CreateAccounts() As List(Of Account)
Dim list As New List(Of Account)()
list.Add(New Account() With {.UserName = "Nick White", .RegistrationDate = Date.Today})
list.Add(New Account() With {.UserName = "Jack Rodman", .RegistrationDate = New Date(2009, 5, 10)})
list.Add(New Account() With {.UserName = "Sandra Sherry", .RegistrationDate = New Date(2008, 12, 22)})
list.Add(New Account() With {.UserName = "Sabrina Vilk", .RegistrationDate = Date.Today})
list.Add(New Account() With {.UserName = "Mike Pearson", .RegistrationDate = New Date(2008, 10, 18)})
Return list
End Function
End Class
Public Class Account
Public Property UserName() As String
Public Property RegistrationDate() As Date
End Class
End Namespace
See Also