How to: Access the ASPxDocumentViewer and ASPxWebDocumentViewer Controls 如何:访问 ASPx 文档查看器和 ASPxWeb 文档查看器控件

This example demonstrates how to access the ASPxDocumentViewer and ASPxWebDocumentViewer controls used to display reports in ASP.NET XAF applications.

此示例演示如何访问用于在ASP.NET XAF 应用程序中显示报表的 ASPx 文档查看器和 ASPxWeb 文档查看器控件。

 

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 in an ASP.NET XAF application, a Detail View is displayed in a popup or main window (depending on the ReportsAspNetModuleV2.DesignAndPreviewDisplayMode value). This Detail View contains a single View Item which creates a web control used to display a report. The particular View Item and control types depend on the ReportsAspNetModuleV2.ReportViewerType property value (HTML5 or ASP).

当用户在ASP.NET XAF 应用程序中预览报表时,详细信息视图将显示在弹出窗口或主窗口中(具体取决于"报告AspNetModuleV2.DesignandPreviewDisplayMode"值)。此详细信息视图包含单个视图项,该视图项创建用于显示报表的 Web 控件。特定的视图项和控件类型取决于报告AspNetModuleV2.报表查看器类型属性值(HTML5 或 ASP)。

 

ReportViewerType ValueView Item TypeControl Type
HTML5 ReportWebViewerDetailItem ASPxWebDocumentViewer
ASP ReportViewerDetailItem ASPxDocumentViewer

 

To access this View Item, implement a Controller that targets the ReportViewer_DetailView_V2 Detail View (this Detail View identifier is specified via the ReportsAspNetModuleV2.ReportViewDetailViewWebName constant). Pass the View Item type as the generic parameter of the CompositeView.GetItems<T> method. The first element of the returned list will be the required View Item, because there is a single report viewer item in the View. Then, you can handle the View Item's ViewItem.ControlCreated event and use the ReportViewer property to access the ASPxDocumentViewer or ASPxWebDocumentViewer control.

要访问此视图项,实现一个控制器,该控制器面向ReportViewer_DetailView_V2详细信息视图(此详细信息视图标识符通过报告AspNetModuleV2.报告视图详细信息视图WebName常量指定)。将视图项类型作为复合视图的泛型参数。getItems<T>方法。返回列表的第一个元素将是所需的视图项,因为视图中有一个报表查看器项。然后,您可以处理 ViewItem.Control创建事件,并使用报表查看器属性访问 ASPx 文档查看器或 ASPxWeb 文档查看器控件。

Example for an ASPxWebDocumentViewer (ReportViewerType is HTML5)

ASPxWeb文档查看器的示例(报表查看器类型是 HTML5)

复制代码
using DevExpress.ExpressApp;
using DevExpress.ExpressApp.ReportsV2.Web;
// ...
public class CustomizeReportViewerController : ViewController<DetailView> {
    public CustomizeReportViewerController() {
        TargetViewId = ReportsAspNetModuleV2.ReportViewDetailViewWebName;
    }
    protected override void OnActivated() {
        base.OnActivated();
        ReportWebViewerDetailItem reportViewItem =  
            ((DetailView)View).GetItems<ReportWebViewerDetailItem>()[0] as ReportWebViewerDetailItem;
        reportViewItem.ControlCreated += delegate(object sender, EventArgs e) {
            // Access client-side events of the ASPxWebDocumentViewer control
            reportViewItem.ReportViewer.ClientSideEvents.Init = 
                "function(s, e) { s.previewModel.reportPreview.zoom(0.7); }"; 
        };
    }
}
复制代码

 

Example for an ASPxDocumentViewer (ReportViewerType is ASP)

ASPx 文档查看器的示例(报表查看器类型为 ASP)

复制代码
using DevExpress.ExpressApp;
using DevExpress.ExpressApp.ReportsV2.Web;
// ...
public class CustomizeReportViewerController : ViewController<DetailView> {
    public CustomizeReportViewerController() {
        TargetViewId = ReportsAspNetModuleV2.ReportViewDetailViewWebName;
    }
    protected override void OnActivated() {
        base.OnActivated();
        ReportViewerDetailItem reportViewItem =  
            ((DetailView)View).GetItems<ReportViewerDetailItem>()[0] as ReportViewerDetailItem;
        reportViewItem.ControlCreated += delegate(object sender, EventArgs e) {
            // Access settings of the ASPxDocumentViewer control
            reportViewItem.ReportViewer.SettingsReportViewer.PageByPage = false;
        };
    }
}
复制代码

 

Important 重要
A reference to the DevExpress.XtraReports.v19.2.Web.dll assembly is required to compile these examples.
需要引用 DevExpress.XtraReports.v19.2.Web.dll 程序集来编译这些示例。
posted @   code first life  阅读(735)  评论(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
点击右上角即可分享
微信分享提示