How to: How to Access the ReportViewer Control: Access Report Viewer control

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

This example demonstrates how to access a report for display in a report viewer control XAF mobile applications.

 

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

In this topic, suppose you have a report using the XAF application V2 module, and you create one or more reports (see Report Overview V2 module).

 

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.

When the user preview the report, the mobile application displays contain detailed information view of a single item view - Report Viewer moving items. This view item wrap Report Viewer 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.

Access to view the project in accordance with the following procedure.

  • Create a new object view controller [view type, object type] offspring. ViewType the parameters of the controller to "View details" will ObjectType parameter to IReportDataV2 - persistent storage class interface for reports.
  • In OnActivated overridden method in the view item type as a generic parameter GetItems <T> () method of transmission.
  • Control handles view item create an event, and use the ReportViewer property access controls.

 

The following code demonstrates this Controller:

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 Note
Only use the BeforeInitialize or OnCustomize properties in one Controller.
Only use "before initiating" or "Custom" property in a controller.

Guess you like

Origin www.cnblogs.com/foreachlife/p/How-to-Access-the-ReportViewer-Control.html