Skip to main content
.NET Framework 4.5.2+

How to: Use Function Criteria Operators to Filter List Views

  • 3 minutes to read

The eXpressApp Framework provides various approaches to filter List Views: on data source level, via the Application Model and on the UI specific level. In each of these approaches, you may need to set static variables as filter criteria values. For example, the filter “Task.DueDate must be set to the current date” needs the CurrentDate variable, calculated every time it is required. For this purpose, the use Function Criteria Operators. They represent functions you can use in criteria. In this topic, you will learn how to use these Function Criteria Operators when setting filter criteria for the Task List View. To see a full list of built-in Function Criteria Operators and learn how to implement custom ones, refer to the Function Criteria Operators topic.

Since the technique for using Function Criteria Operators is common to any filtering approach, both in code and the Model Editor, the ListViewFilterAttribute will be chosen for demonstration.


Before reviewing the example, be sure to read the “Important Remark on the DateTime Function Criteria Operators” section of the Function Criteria Operators topic.


A complete sample project is available in the DevExpress Code Examples database at

The following code demonstrates how to implement various filters using the LocalDateTimeToday, LocalDateTimeLastWeek and LocalDateTimeThisWeek Function Criteria Operators:

using DevExpress.ExpressApp.Model;
using DevExpress.ExpressApp.SystemModule;
[ListViewFilter("Today", "GetDate([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", @"GetDate([DueDate]) > LocalDateTimeLastWeek() AND 
    GetDate([DueDate]) <= ADDDAYS(LocalDateTimeLastWeek(), 5)")]
[ListViewFilter("This week", @"GetDate([DueDate]) > LocalDateTimeThisWeek() AND 
    GetDate([DueDate]) <= ADDDAYS(LocalDateTimeThisWeek(), 5)")]
public class Task : BaseObject {
    public virtual DateTime DueDate { get; set; }

// Make sure that you use options.UseChangeTrackingProxies() in your DbContext settings.

The code above generates several Filter child nodes for the Application Model‘s Views | Task_ListView node:



You could generate these nodes manually in the Model Editor.

The following image demonstrates the Filter Action that contains all the filters provided by the code above:

Read-OnlyParameters for List Views_Result