When an end user applies a filter to a grid, the filter is shown within the Filter Panel. If the AllowMRUFilterList option is enabled, the user can access recently used filters and apply them.
This example shows how to allow the user to rename filters as needed:
public partial class Main : XtraForm {
FilterNameProvider provider;
public Main() {
InitializeComponent();
gridView1.OptionsView.FilterCriteriaDisplayStyle = FilterCriteriaDisplayStyle.Text;
recordBindingSource.DataSource = DataHelper.GetData(10);
provider = new FilterNameProvider(gridView1) { AllowSettingFilterNames = true };
}
}
The FilterNameProvider.GridFilters
property is marked with the XtraSerializableProperty
attribute. The following code serializes custom filter names with the grid layout:
void OnSaveLayoutButtonClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e) {
gridView1.SaveLayoutToXmlEx(provider, filePath);
}
The following code deserializes (restores) grid filters:
void OnRestoreLayoutButtonClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e) {
gridView1.RestoreLayoutFromXmlEx(provider, filePath);
}
GridFitlerItem
objects are not created automatically. You should declare a special method in the FilterNameProvider
class that creates such objects. Name this method according to the following pattern: "XtraCreateItem". In this example, this is the XtraCreateGridFiltersItem
method:
internal GridFitlerItem XtraCreateGridFiltersItem(XtraItemEventArgs e) {
GridFitlerItem fItem = new GridFitlerItem();
GridFilters.Add(fItem);
return fItem;
}
- FilterNameProvider.cs (VB: FilterNameProvider.vb)
- Main.cs (VB: Main.vb)
(you will be redirected to DevExpress.com to submit your response)