Ticket T487019
Visible to All Users

How to display an embedded report preview form in a Web app from a hyper link included into email

created 8 years ago (modified 8 years ago)

Hi team support

How to bind devexpress report class to report viewer in XAF webUserControl at runtime?
my purpose is, I want to show report in detail view by query string parameter
and I created a reportviewer in web user control in xaf web application project.
I am following this step for create web user control and add to web detail view

https://documentation.devexpress.com/#eXpressAppFramework/CustomDocument114160

it's possible or not if I was created report-class in module project, and I want to call it and show in report viewer in web application web user control.

bellow as my source code in webusercontrol:

C#
public partial class WebReportControl : System.Web.UI.UserControl, IComplexControl { protected void Page_Load(object sender, EventArgs e) { } void IComplexControl.Setup(IObjectSpace objectSpace, XafApplication application) { //how to bind report viewer to devexpress report class in here //... string id = Request.QueryString["id"]; //my report class was created in module project SampleReport rpt = new SampleReport(); //filter illustration rpt.FilterString = string.Format("ID={0}", id); rptViewer. } void IComplexControl.Refresh() { } }

UPDATED by Dennis (DevExpress Support):
I want to create scenario link of approval page, by user. When user click link approval from email, my application directing to show a detail report in bottom and in toolbar have 2 simple action button approve and reject, I am also try to create  In-Place Reports  but user must click show report for showing report preview and this is a intent pop up. I just think about I must be create custom control for show report in detail view with have 2 action button in toolbar for approve or reject. or you have alternation solution without create webusercontrol ?

Answers approved by DevExpress Support

created 8 years ago (modified 8 years ago)

Hello,

Sure, it is possible to bind an XtraReport class designed in the platform-agnostic module to a report viewer. Basically, you will need to use a solution recommended for the ASP.NET WebForms platform by the XtraReports product. I remember you asked a similar question in the past at T384509 where my colleague gave you a link to an example that used the ASPxDocumentViewer control for that purpose.
Would you please review this example or follow the XtraReports documentation (Reporting > Examples > Publish Your Reports > Create a Print Preview > How to: Add a Print Preview to a Web Application)?

>>my purpose is, I want to show report in detail view by query string parameter
Why do you need a custom user control to preview for your report in the first place? I am asking because XAF ships with a built-in ReportsV2 module that makes accomplishing such typical tasks easier. Even if you want to supply a custom query parameter, it is also feasible with our module as described at How to show report with simple action? or using other solutions. If you attach your report definition or describe your business task in greater detail, it is possible that I can give you more precise solutions as well.

UPDATED:

We have found an alternative custom-tailored solution using the built-in ReportsV2 features.

  1. Set the ReportsAspNetModuleV2 > DesignAndPreviewDisplayMode option to DetailView.

  2. Override the OnLoad method of the YourSolutionName.Web/Default.aspx.xx file as shown below:

C#
using System; using System.Collections.Generic; using System.Web.UI; using DevExpress.Data.Filtering; using DevExpress.ExpressApp; using DevExpress.ExpressApp.ReportsV2; using DevExpress.ExpressApp.Templates; using DevExpress.ExpressApp.Web; using DevExpress.ExpressApp.Web.Templates; using DevExpress.ExpressApp.Web.Templates.ActionContainers; using DevExpress.Persistent.BaseImpl; public partial class Default : BaseXafPage { protected override ContextActionsMenu CreateContextActionsMenu() { return new ContextActionsMenu(this, "Edit", "RecordEdit", "ObjectsCreation", "ListView", "Reports"); } public override Control InnerContentPlaceHolder { get { return Content; } } protected override void OnLoad(EventArgs e) { base.OnLoad(e); string nameParameter = Request.Params["ReportName"]; if(!string.IsNullOrEmpty(nameParameter)) { var window = WebWindow.CurrentRequestWindow; if(window.View == null) { IObjectSpace os = window.Application.CreateObjectSpace(typeof(ReportDataV2)); var data = os.FindObject<ReportDataV2>(new BinaryOperator("DisplayName", nameParameter)); if(data != null) { string reportContainerHandle = ReportDataProvider.ReportsStorage.GetReportContainerHandle(data); window.GetController<ReportServiceController>().ShowPreview(reportContainerHandle); } } } } }

This code reads a report name from the current request parameters and invokes the report preview programmatically as per Concepts > Extra Modules > Reports V2 Module > Invoke the Report Preview from Code

  1. In the YourSolutionName.Module.Web project, declare the required Controller with custom Approve and Reject Actions and manage their visibility depending on the request parameters:
C#
using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Web.UI; using DevExpress.ExpressApp; using DevExpress.ExpressApp.Actions; using DevExpress.ExpressApp.ReportsV2; using DevExpress.ExpressApp.Web; namespace MainDemo.Module.Web.Controllers { public class ReportDataController : ObjectViewController<DetailView, IReportDataV2> { public ReportDataController() { new SimpleAction(this, "Approve", DevExpress.Persistent.Base.PredefinedCategory.View); new SimpleAction(this, "Reject", DevExpress.Persistent.Base.PredefinedCategory.View); } protected override void OnActivated() { base.OnActivated(); bool active = WebWindow.CurrentRequestPage != null && !string.IsNullOrEmpty(WebWindow.CurrentRequestPage.Request.Params["ReportName"]); foreach(var item in Actions) { item.Active["OnlyForCustomReportUrl"] = active; } } } }
  1. If your web application has the security system enabled, additionally implement a solution from the How to open a View specified in an external link after logging in to a Web application with the security system enabled? thread.

  2. Once you do this, you can pass the required report name to URL and include it into your email, e.g., as follows: http://localhost:50292/Default.aspx?ReportName=Contacts%20Report

    Show previous comments (1)

      in attachment as draft design

      Dennis Garavsky (DevExpress) 8 years ago

        Thanks for your clarification! Since opening links from an email is involved here, we think that the best solution here would, indeed, be creating a custom user control as per the documentation we provided earlier.
        The built-in ReportsV2 features we discussed are not appropriate for this. I was asking you for more use-case scenario details because I thought that the ReportsAspNetModuleV2 > DesignAndPreviewDisplayMode option would suffice, but, unfortunately, it would not.
        Let us know if you experience any further difficulties.

        Dennis Garavsky (DevExpress) 8 years ago

          We have found an alternative custom-tailored solution using the built-in ReportsV2 features. I have updated my original answer accordingly.

          Disclaimer: The information provided on DevExpress.com and affiliated web properties (including the DevExpress Support Center) is provided "as is" without warranty of any kind. Developer Express Inc disclaims all warranties, either express or implied, including the warranties of merchantability and fitness for a particular purpose. Please refer to the DevExpress.com Website Terms of Use for more information in this regard.

          Confidential Information: Developer Express Inc does not wish to receive, will not act to procure, nor will it solicit, confidential or proprietary materials and information from you through the DevExpress Support Center or its web properties. Any and all materials or information divulged during chats, email communications, online discussions, Support Center tickets, or made available to Developer Express Inc in any manner will be deemed NOT to be confidential by Developer Express Inc. Please refer to the DevExpress.com Website Terms of Use for more information in this regard.