Skip to main content
A newer version of this page is available. .

ListViewFilter Attribute

  • 2 minutes to read

Apply this attribute to a business class to specify a filter for the List View that will display this class’ objects. The specified filter will be loaded to the Application Model as a child node of the appropriate Filters node. All the filters added to a ListView node are represented by the built-in SetFilter Action’s items in the drop-down window. An end-user can select an item to apply the required filter to the current List View.

using DevExpress.ExpressApp.Model;
using DevExpress.ExpressApp.SystemModule;
//...
[DefaultClassOptions]
[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;
   [ModelDefault("EditMask","d")]
   public DateTime DueDate {
      get {
         return dueDate;
      }
      set {
         SetPropertyValue(nameof(DueDate), ref dueDate, value);      }
   }
}

For details, see ListViewFilterAttribute.

Note

The filters specified via the ListView Filter attribute are added to all autogenerated ListView nodes whose ModelClass attribute is set to the class to which the attribute is applied. The attribute does not add filters to nodes that are created manually or cloned in the Model Editor. The SetFilter Action is activated for root and nested List Views, since only the MainForm and DetailViewForm Windows Forms Templates and the Default ASP.NET Template contain the Filters Action Container that displays this Action.

See Also