How to: Access the ReportViewer Control 如何:访问报表查看器控件

This example demonstrates how to access the ReportViewer control used to display reports in XAF Mobile applications.

此示例演示如何访问用于在 XAF 移动应用程序中显示报表的报表查看器控件。

 

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).

在本主题中,假定您有一个使用报表 V2 模块的 XAF 应用程序,并且您创建了一个或多个报表(请参阅报表 V2 模块概述)。

 

When a user previews a report, a Mobile application displays a Detail View that contains a single View Item - MobileReportViewerViewItem. This View Item wraps the ReportViewer control.

当用户预览报表时,移动应用程序将显示包含单个视图项的详细信息视图 - 移动报表查看器查看项目。此视图项换行报表查看器控件。

 

Follow the steps below to access the View Item.

  • Create a new ObjectViewController<ViewType, ObjectType> descendant. Set the Controller's ViewType parameter to DetailView and the ObjectType parameter to IReportDataV2 - the interface that persistent classes use to store reports.

  • In the overridden OnActivated method, pass the View Item type as the GetItems<T>() method's generic parameter.

  • Handle the View Item's ControlCreated event and use the ReportViewer property to access the control.

按照以下步骤访问查看项目。

  • 创建新的对象视图控制器 [视图类型,对象类型] 后代。将控制器的 ViewType 参数设置为"详细信息视图",将 ObjectType 参数设置为 IReportDataV2 - 持久类用于存储报表的接口。
  • 在重写的 OnActivated 方法中,将视图项类型作为 GetItems<T>() 方法的泛型参数传递。
  • 处理视图项的控件创建事件,并使用 ReportViewer 属性访问控件。

 

The following code demonstrates this Controller:

以下代码演示此控制器:

复制代码
using System;
using DevExpress.ExpressApp;
using DevExpress.ExpressApp.ReportsV2;
using DevExpress.ExpressApp.ReportsV2.Mobile;
// ...
public class ReportsCustomizeController : ObjectViewController<DetailView, IReportDataV2> {
    // ...
    protected override void OnActivated() {
        base.OnActivated();
        MobileReportViewerViewItem reportViewItem = 
        View.GetItems<MobileReportViewerViewItem>()[0] as MobileReportViewerViewItem;
        reportViewItem.ControlCreated += delegate (object sender, EventArgs e) {
            MobileReportViewerViewItem mobileReportViewerViewItem = (MobileReportViewerViewItem)sender;
            mobileReportViewerViewItem.ReportViewer.BeforeInitialize = 
                @"function(args) { args.reportViewerSettings.mobileModeSettings = { readerMode: true }; }";
            //mobileReportViewerViewItem.ReportViewer.OnCustomize = 
                //@"function(args) { args.previewModel.reportPreview.zoom(0.7); }";
        };
    }
}
复制代码

 

Note 注意
Only use the BeforeInitialize or OnCustomize properties in one Controller.
仅在一个控制器中使用"初始化前"或"自定义"属性。
posted @   code first life  阅读(199)  评论(0编辑  收藏  举报
编辑推荐:
· Linux系列:如何用 C#调用 C方法造成内存泄露
· AI与.NET技术实操系列(二):开始使用ML.NET
· 记一次.NET内存居高不下排查解决与启示
· 探究高空视频全景AR技术的实现原理
· 理解Rust引用及其生命周期标识(上)
阅读排行:
· 阿里最新开源QwQ-32B,效果媲美deepseek-r1满血版,部署成本又又又降低了!
· 单线程的Redis速度为什么快?
· SQL Server 2025 AI相关能力初探
· AI编程工具终极对决:字节Trae VS Cursor,谁才是开发者新宠?
· 展开说说关于C#中ORM框架的用法!
历史上的今天:
2015-01-08 CSharp Similarities and Differences
2015-01-08 Nemerle Quick Guide
点击右上角即可分享
微信分享提示