How to: Access the ReportViewer Control

This example demonstrates how to access the ReportViewer control used to display reports in 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).

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.

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.