FilterValue Class
Represents an item within the Header Filter.
Namespace: DevExpress.Web
Assembly: DevExpress.Web.v24.2.dll
Declaration
Related API Members
The following members return FilterValue objects:
Remarks
End-users can filter column values via the Filter Dropdown if the ASPxGridSettings.ShowHeaderFilterButton option is enabled. To invoke the filter dropdown, an end-user should click on the filter button. The ASPxGridView.HeaderFilterFillItems event is raised before the filter dropdown is shown, and enables you to provide custom filter items. Individual filter items are represented by a FilterValue object.
The FilterValue class provides the FilterValue.DisplayText, FilterValue.Value and FilterValue.Query properties that enable the item’s caption, filter value (Equals to condition) and complex filter expression to be specified, respectively. The filter expression specified by the FilterValue.Query property takes priority over the filter expression specified by the FilterValue.Value property.
Example
protected void ASPxGridView1_HeaderFilterFillItems(object sender,
DevExpress.Web.ASPxGridViewHeaderFilterEventArgs e)
{
if (e.Column.FieldName != "FieldName") return;
e.Values.Clear();
// Example 1: Equals to 50
FilterValue filterItem1 = new FilterValue();
filterItem1.DisplayText = "Filter Value1";
filterItem1.Value = "50";
e.Values.Add(filterItem1);
// Example 2: Equals to 100
FilterValue filterItem2 = new FilterValue("Filter Value2", "100");
e.Values.Add(filterItem2);
// Example 3: Greater than 50
FilterValue filterItem3 =
new FilterValue("> 50", null, string.Format("[FieldName] > {0}", 50));
e.Values.Add(filterItem3);
// Example 4: Clear Filtering
FilterValue showAllItem = FilterValue.CreateShowAllValue("Show All");
// FilterValue showAll =
//new FilterValue("Show All", null, FilterValue.FilterAllQuery);
e.Values.Add(showAllItem);
}