In this lesson, you will learn how to filter a List View. Three techniques, based on different scenarios, will be illustrated. For this lesson, a filter will be applied to the Contact List View.

在本课中,您将学习如何筛选列表视图。将说明基于不同方案的三种技术。在本课中,筛选器将应用于联系人列表视图。

Note 注意
Before proceeding, take a moment to review the following lessons.

在继续之前,请花点时间复习以下课程。

  • Inherit from the Business Class Library Class (XPO/EF)
  • Implement Custom Business Classes and Reference Properties (XPO/EF)
  • Set a One-to-Many Relationship (XPO/EF)
  • Filter Lookup Editor Data Source
  • Place an Action in a Different Location
  • 从商务舱库类 (XPO/EF) 继承
  • 实现自定义业务类和参考属性 (XPO/EF)
  • 设置一对多关系 (XPO/EF)
  • 筛选器查找编辑器数据源
  • 将操作放置在其他位置

Activate a Filter Action

激活筛选器操作

Use this approach to enable an end-user to apply predefined filters to a particular List View. With this approach, the SetFilter Action (whose items represent predefined filters) is visible in the user interface. This action is activated for List Views only. Predefined filters can be added in the Application Model, and are represented by child nodes of the Views | <ListView> | Filters node (see Filters Application Model Node).

使用此方法使最终用户能够将预定义的筛选器应用于特定的列表视图。使用此方法,SetFilter 操作(其项表示预定义的筛选器)在用户界面中可见。此操作仅针对列表视图激活。预定义的筛选器可以添加到应用程序模型中,并由视图的子节点表示 |<ListView>*筛选器节点(请参阅筛选器应用程序模型节点)。

  • Invoke the Model Editor for the MySolution.Module project. Navigate to the Views | MySolution.Module.BusinessObjects | Contact_ListView node. Right-click the Filters child node and select New | ListViewFilterItem. For the new node, set the Id property to "Development Department Contacts". To specify a criteria, set the Criteria property to the "[Department.Title] = 'Development Department'" value.

  • 调用 MySolution.模块项目的模型编辑器。导航到视图 |My解决方案.模块.业务对象 |Contact_ListView节点。右键单击"筛选器子节点"并选择"新建 |列表视图筛选器项。对于新节点,将 Id 属性设置为"开发部门联系人"。要指定条件,请将"标准"属性设置为"[部门.标题] = "开发部门""值。

Note 注意
The Criteria property value must be specified using the Criteria Language Syntax. To simplify this task, you can invoke the Filter Builder dialog by clicking the ellipsis button () to the right of the Criteria value. Within this dialog, you can design a criteria expression using the visual Filter Builder.

必须使用"条件语言语法"指定"条件"属性值。要简化此任务,可以通过单击条件值右侧的省略号按钮 (EllipsisButton) 来调用"筛选器生成器"对话框。在此对话框中,可以使用可视筛选器生成器设计条件表达式。

  • Add one more Filter node to the Filters node as defined above. Set the Id property to "Developers" and the Criteria property - to "Position.Title = 'Developer'".

  • 如上定义,向筛选器节点再添加一个筛选器节点。将 Id 属性设置为"开发人员"和"条件"属性 - 设置为"位置.标题 = "开发人员"。。

  • To be able to view all Contact objects in the List View, add one more Filter node to the Filters node, as defined above. Set the Id property to "All Contacts" and leave the Criteria property empty.

  • 为了能够查看列表视图中的所有联系人对象,请向筛选器节点再添加一个筛选器节点,如上所述。将 Id 属性设置为"所有联系人",并将"条件"属性保留为空。

  • For the Filters node, set the CurrentFilterID property to "Developers". Save the changes.

  • 对于筛选器节点,将"当前筛选器ID"属性设置为"开发人员"。保存更改。

  • Run the WinForms or ASP.NET application and select the Contacts item in the navigation control. Notice that the SetFilter Action is now available.
  • 运行 WinForms 或ASP.NET应用程序,并在导航控件中选择"联系人"项。请注意,"设置筛选"操作现在可用。

Use the Model Editor's Application | Views | ListView Node

使用模型编辑器的应用程序 |视图 |列表视图节点

Use this approach to filter a List View via the Model Editor. Filters applied with the Model Editor cannot be changed by end-users.

使用此方法通过模型编辑器筛选列表视图。最终用户无法更改与模型编辑器一起应用的筛选器。

  • Run the Model Editor for the MySolution.Module project. Navigate to the Views | MySolution.Module.BusinessObjects | Contact_ListView node. Set its Criteria property to "Position.Title = 'Developer'".

  • 运行 MySolution.模块项目的模型编辑器。导航到视图 |My解决方案.模块.业务对象 |Contact_ListView节点。将其"条件"属性设置为"位置.标题 = "开发人员"。。

  • Run the WinForms or ASP.NET application. Select the Contacts item in the navigation control and check to see if the Contact objects in the List View are filtered.
  • 运行 WinForms 或ASP.NET应用程序。选择导航控件中的"联系人"项并检查是否筛选了"列表"视图中的"联系人"对象。

Filter on Data Source Level

在数据源级别上筛选

Use this approach if you need to apply filters that will not be changed at runtime or via the Model Editor.

如果需要应用在运行时或通过模型编辑器不会更改的筛选器,请使用此方法。

  • Create a View Controller and generate the Activated event handler, as defined in the Add a Simple Action tutorial, as well as the other lessons from the Extend Functionality section.
  • Replace the generated code for the Activated event handler with the following code.

  • 创建视图控制器并生成已激活的事件处理程序,如"添加简单操作"教程中定义,以及"扩展功能"部分中的其他课程。

  • 将已激活事件处理程序生成的代码替换为以下代码。

    using DevExpress.Data.Filtering;
    using MySolution.Module.BusinessObjects;
    // ...
    public partial class FilterListViewController : ViewController {
    // ...
    private void FilterListViewController_Activated(object sender, EventArgs e) {
    if ((View is ListView) & (View.ObjectTypeInfo.Type == typeof(Contact))) {
    ((ListView)View).CollectionSource.Criteria["Filter1"] = new BinaryOperator(
    "Position.Title", "Developer", BinaryOperatorType.Equal);
    }
    }
    }
  • Run the WinForms or ASP.NET application and select the Contacts item in the navigation control. Check to see if the Contact objects in the List View are filtered.
  • 运行 WinForms 或ASP.NET应用程序,并在导航控件中选择"联系人"项。检查是否筛选了列表视图中的"联系人"对象。

Filter List Views 筛选器列表视图的更多相关文章

  1. 表示层设计模式:Intercepting Filter(截取筛选器)模式

     上下文  问题  影响因素  解决方案  变体  示例  结果上下文  相关模式  致谢  上下文 对于任何一个曾经从头建立 Web 应用程序的人来说,他们都会有这样的体会:这项任务所需要的独立完成 ...

  2. SharePoint 2013无代码实现列表视图的时间段动态筛选

    本文介绍两种为列表视图设置时间段筛选器的方法.其中,第一个方法用于SharePoint Server,第二个方法同时还能用于SharePoint Foundation. 方法一:日期筛选器Web部件 ...

  3. Filter 筛选器(一)之 ActionFilter-- IAsyncActionFilter 和 ActionFilterAttribute

    微软官网例子:Filter筛选器 使用场景(执行顺序): IAsyncActionFilter 使用异步actionFilter 只需要实现 他的 :OnActionExecutionAsync 方法 ...

  4. Android列表视图(List View)

    Android列表视图(ListView) ListView是一个显示滚动项列表的示视图组(viewgroup),通过使用适配器(Adapter)把这些列表项自动插入到列表中.适配器比如从一个数组或是 ...

  5. asp.net core 2.2 中的过滤器/筛选器(上)

    ASP.NET Core中的过滤器/筛选器 通过使用 ASP.NET Core MVC 中的筛选器,可在请求处理管道中的特定阶段之前或之后运行代码. 注意:本主题不适用于 Razor 页面. ASP. ...

  6. tableau-交互筛选器

    欢迎观看这段关于“交互筛选器”的视频.   将字段拖到筛选器功能区就可以轻松执行筛选,但是如果我们希望能够直接从视图中修改筛选器 选择项,那该怎么办?如果我们在可看到“子类别”字段的任何位置右键单击, ...

  7. jQuery的基本使用及选择器和筛选器

    回顾 事件 鼠标clickdblclickcontextmenumouseentermouseleavemousemovemousedownmouseup​键盘keydownkeyupkeypress ...

  8. abp(net core)+easyui+efcore实现仓储管理系统——展现层实现增删改查之列表视图(七)

    abp(net core)+easyui+efcore实现仓储管理系统目录 abp(net core)+easyui+efcore实现仓储管理系统——ABP总体介绍(一) abp(net core)+ ...

  9. drf过滤器、分页器、筛选器的应用

    一.drf 提供的过滤器(ordering) views.py from rest_framework.generics import ListAPIView from . import models ...

随机推荐

  1. C#语法--委托,架构的血液

    委托的定义 什么是委托? 委托实际上是一种类型,是一种引用类型. 微软用delegate关键字来声明委托,delegate与int,string,double等关键字一样.都是声明用的. 下面先看下声 ...

  2. 学习索引结构的一些案例——Jeff Dean在SystemML会议上发布的论文(下)

    [摘要] 除了范围索引之外,点查找的Hash Map在DBMS中起着类似或更重要的作用. 从概念上讲,Hash Map使用Hash函数来确定性地将键映射到数组内的随机位置(参见图[9 ],只有4位开销 ...

  3. http状态码_____ 204/206/200

    HTTP的状态码有很多种,主要有五个大类 1xx(临时响应) 2xx(成功) 3xx(已重定向) 4xx(请求错误) 5xx(服务器错误) 每个大类还对应一些具体的分类.平时我们接触比较多的是200. ...

  4. 【重温基础】JS中的常用高阶函数介绍

    Ps. 晚上加班到快十点,回来赶紧整理整理这篇文章,今天老大给我推荐了一篇文章,我从写技术博客中收获到了什么?- J_Knight_,感受也是很多,自己也需要慢慢养成记录博客的习惯,即使起步艰难,难以 ...

  5. 阿里巴巴的26款Java开源项目

    阿里巴巴的26款Java开源项目 开源展示了人类共同协作,成果分享的魅力.没有任何一家网络公司可以不使用开源技术,仅靠自身技术发展起来.“取之于开源,用之于开源,才能促进开源的良性发展”,阿里巴巴各个 ...

  6. 你不会还在用这8个错误的SQL写法吧?

    1.LIMIT 语句 分页查询是最常用的场景之一,但也通常也是最容易出问题的地方.比如对于下面简单的语句,一般 DBA 想到的办法是在 type, name, create_time 字段上加组合索引 ...

  7. 想要金九银十面试通关,不懂 Java多线程肯定是不行的!

    作者 | 纳达丶无忌 如果对什么是线程.什么是进程仍存有疑惑,请先 Google 之,因为这两个概念不在本文的范围之内. 用多线程只有一个目的,那就是更好的利用 CPU 的资源,因为所有的多线程代码都 ...

  8. django----多对多三种创建方式 form组件

    目录 多对多三种创建方式 全自动 全手动 半自动 form组件 基本使用 form_obj 及 is_valid() 前端渲染方式 取消前端自动校验 正则校验 钩子函数(Hook方法) cleaned ...

  9. 小白学 Python 爬虫(23):解析库 pyquery 入门

    人生苦短,我用 Python 前文传送门: 小白学 Python 爬虫(1):开篇 小白学 Python 爬虫(2):前置准备(一)基本类库的安装 小白学 Python 爬虫(3):前置准备(二)Li ...

  10. CCF-CSP题解 201803-3 URL映射

    题目要求写一个简易的URL规则和URL地址匹配的程序. 说说我的思路. 将URL规则和地址都截成片段用结构体\(<type, str[]>\)存储.对于URL规则,\(type\)为0代表 ...