How to: Filter a Report Parameter's Lookup 如何:筛选报表参数的查找

When your report has a report parameter of a persistent type, the parameter value is specified using a lookup editor. However, if there is a large amount of objects in the lookup, it may be inconvenient to scroll and select the desired parameter value. This example describes how to filter the parameter's lookup to reduce the number of available values.

当报表具有持久类型的报表参数时,将使用查找编辑器指定参数值。但是,如果查找中存在大量对象,则滚动并选择所需的参数值可能不太方便。此示例介绍如何筛选参数的查找以减少可用值的数量。

 

FilterReportParameterLookup

 

Note 注意
  • This example is applicable to WinForms and ASP.NET applications. However, in WinForms applications, the lookup editor already has the built-in filtering support. So, the customizations demonstrated here make sense in ASP.NET applications only. Mobile applications do not support the report preview mechanism, so the approach described in this topic cannot be implemented in the Mobile platform.
  • In this topic, it is assumed that you have an XAF application that uses the Reports V2 Module, and you have created one or more reports (see Reports V2 Module Overview).
  • 此示例适用于 WinForms 和ASP.NET应用程序。但是,在 WinForms 应用程序中,查找编辑器已经具有内置的筛选支持。因此,此处演示的自定义仅在ASP.NET应用程序中有意义。移动应用程序不支持报表预览机制,因此本主题中描述的方法无法在移动平台中实现。
  • 在本主题中,假定您有一个使用报表 V2 模块的 XAF 应用程序,并且您创建了一个或多个报表(请参阅报表 V2 模块概述)。
 
Tip 提示
A complete sample project is available in the DevExpress Code Examples database at http://www.devexpress.com/example=T319024
完整的示例项目可在 DevExpress 代码示例数据库中找到,http://www.devexpress.com/example=T319024

.

Filter the Lookup Parameter Using the Additional Data Source

使用其他数据源筛选查找参数

Add an extra CollectionDataSource data source to your report from the Toolbox. In the Properties window, set the DataSourceBase.ObjectTypeName property to the type of the parameter to be filtered. Specify the desired filter using the CollectionSourceBase.Criteria property.

从工具箱向报表添加额外的收集数据源数据源。在"属性"窗口中,将 DataSourceBase.ObjectTypeName 属性设置为要筛选的参数的类型。使用"收集来源Base.Criteria"属性指定所需的筛选器。

FilterReportParameterLookup1

 

Determine the key type used in the parameter's type (passed to ObjectTypeName in the previous step). Create a parameter of the same key type (e.g., Guid or int). Enable "Support the collection of standard values". Specify the DataSource, created in the previous step. Set DisplayMember to the name of the property storing the human-readable identifier of the parameter (e.g., Name). Set ValueMember to the name of the parameter's key property (e.g., Oid).

确定参数类型中使用的键类型(在上一步中传递给 ObjectTypeName)。创建相同键类型的参数(例如,Guid 或 int)。启用"支持收集标准值"。指定在上一步中创建的数据源。将 DisplayMember 设置为属性的名称,该属性存储参数的可读标识符(例如,Name)。将 ValueMEMBER 设置为参数的键属性(例如 Oid)的名称。

FilterReportParameterLookup2

As the result, the parameter's lookup will be filtered according to the specified criteria.

因此,参数的查找将根据指定的条件进行筛选。

Use Cascading Parameters

使用级联参数

The previous section described how to specify a static filter at design time. However, the filtering expression can include other parameter values, so you can use Cascading Parameters to change the filter an runtime when previewing the report. Note that the filtering is performed on the client side in this instance.

上一节介绍了如何在设计时指定静态筛选器。但是,筛选表达式可以包含其他参数值,因此可以使用级联参数在预览报表时更改运行时筛选器。请注意,在此实例中,筛选在客户端上执行。

 

Add the Filter parameter of a string type. Pass the criteria that included a reference to the Filter parameter to the FilterString property of the parameter to be filtered (e.g., "Contains([Name], ?filter)").

添加字符串类型的筛选器参数。将包含对 Filter 参数的引用的条件传递到要筛选的参数的 FilterString 属性(例如,"包含([名称],?筛选器)")。

FilterReportParameterLookup3

As the result, the parameter's lookup will be accompanied with the Filter input field. The lookup will be filtered according to the specified Filter text.

因此,参数的查找将随"筛选器"输入字段一起。将根据指定的筛选器文本筛选查找。

posted @ 2020-01-10 14:39  code first life  阅读(430)  评论(0编辑  收藏  举报