Filters Application Model Node

The Filters Application Model node allows you to add predefined criteria to the built-in SetFilter Action. When selecting a criteria in the Action's drop-down window, the current List View is filtered using this criteria.


Use this technique to filter List Views when you need an end-user to be able to select the required filter. Moreover, the end-users who have access to the Application Model will be able to add or change predefined filters via the Model Editor.

The SetFilter Action is not activated for List Views that have no filters specified in the Filters node. In addition, this Action can be activated for root and nested List Views, since the MainForm and DetailViewForm Windows Forms Templates, and the Default ASP.NET Template contain the Filters Action Container that displays this Action. To learn how to display the Filter Action in a pop-up Window, refer to the Add Actions to a Popup Window topic.

To customize the SetFilter Action's behavior, access it in code. This Action is contained in the FilterController and can be accessed via its FilterController.SetFilterAction property.

Add Filters via the Model Editor

To add items to the SetFilter Action, do the following.

  • Invoke the context menu for the required Views | <ListView> | Filters node and select the Add | ListViewFilterItem menu item.
  • For the new Filter node, specify the ID, Caption and Criteria properties. The Criteria value must be specified using the Criteria Language Syntax. To simplify this task, you can invoke the Filter Builder dialog by clicking an ellipsis button (EllipsisButton) to the right of the Criteria value. Within this dialog, you can visually design a criteria expression.


  • Repeat the previous two steps if needed.
  • Return to the Filters node, specify the default filter via the CurrentFilter property, if needed.

Add Filters in Code

You can add predefined filters in code via the ListViewFilterAttribute. The filters specified via this attribute are added to the Filters node of the ListView node whose IModelObjectView.ModelClass property is set to the class to which the attribute is applied.

using DevExpress.ExpressApp.Model;
using DevExpress.ExpressApp.SystemModule;
[ListViewFilter("Today", "[DueDate] = LocalDateTimeToday()")]
[ListViewFilter("In three days", "[DueDate] >= ADDDAYS(LocalDateTimeToday(), -3) AND 
    [DueDate] < LocalDateTimeToday()")]
[ListViewFilter("In two weeks", "[DueDate] >= ADDDAYS(LocalDateTimeToday(), -14) AND 
    [DueDate] < LocalDateTimeToday()")]
[ListViewFilter("The last week", "[DueDate] > LocalDateTimeLastWeek() AND 
    [DueDate] <= ADDDAYS(LocalDateTimeLastWeek(), 5)")]
[ListViewFilter("This week", "[DueDate] > LocalDateTimeThisWeek() AND 
    [DueDate] <= ADDDAYS(LocalDateTimeThisWeek(), 5)")]
public class Task : BaseObject {
   public Task(Session session) : base(session) {}
   private DateTime dueDate;
   public DateTime DueDate {
      get {
         return dueDate;
      set {
         SetPropertyValue("DueDate", ref dueDate, value);      }

If you are going to add a complex filter, which is difficult to write as a string, add the IModelListViewFilterItem Application Model node in code by implementing a ModelNodesGeneratorUpdater<T> descendant (Generator Updater) for the ModelListViewFiltersGenerator Nodes Generator:

using DevExpress.ExpressApp.Model;
using DevExpress.ExpressApp.Model.Core;
using DevExpress.ExpressApp.SystemModule;
public sealed class Module : ModuleBase {
   // ...   
    public override void AddGeneratorUpdaters(ModelNodesGeneratorUpdaters updaters) {
        updaters.Add(new MyFilterUpdater());          
public class MyFilterUpdater : ModelNodesGeneratorUpdater<ModelListViewFiltersGenerator> {
    public override void UpdateNode(ModelNode node) {                
        IModelListViewFilters filtersNode = (IModelListViewFilters)node;
        if(((IModelListView)filtersNode.Parent).ModelClass.TypeInfo.Type == 
            typeof(MyBusinessClass)) {
            IModelListViewFilterItem myFilter = 
            myFilter.Criteria = "";
            myFilter.Index = 1;
            myFilter.Caption = "My Filter";
            myFilter.Description = "";
            filtersNode.CurrentFilter = myFilter;

To learn about the entire concept of how to extend the Application Model in code, refer to the Extend and Customize the Application Model in Code topic.

To learn how to build criteria, refer to the Ways to Build Criteria topic.

See Also