Blogs

The One With

Silverlight Report Viewer and the XtraReports End User Report Designer - v2010 vol 1

In my previous post I have showed you how to display an XtraReport inside a Silverlight application. The assumptions we made last time were that the reports are created by the developer and that they are compiled into the solution. This is not always the case in the real world. Especially when we are working with XtraReports, because it comes with a full end-user report designer.

To dynamically build the reports on the server and to bypass the default registration mechanism of the IReportService (which uses a fully qualified report type name to create report instances) we will override the IReportService.StartBuild.  We’ll treat the passed in reportTypeName argument as a file name of the report previously saved by the end-user report designer.

End User Report Designer

To load the report file, we’ll use the XtraReport.LoadLayout. For example let’s assume that all our reports are saved into a special ~/Reports folder on the server: 

public class ReportService : DevExpress.XtraReports.Service.ReportService, IReportService {
const string NoDocumentMsg = "There is no such documentId";
const string NoSessionMsg = "there is no session";
const string NoReportMsg = "There is no such report";

const string filePath = "~/Reports";
public override DevExpress.XtraReports.Service.DataContracts.DocumentId StartBuild(string reportTypeName) {
if (Session == null || User == null)
throw new FaultException(NoSessionMsg);
XtraReport report = new XtraReport();
report.LoadLayout(HttpContext.Current.Server.MapPath(filePath + "//" + reportTypeName));
return ReportServiceContainer.Builder.StartBuild(report, Session, null);
}
}

With this new ReportService implementation, you would now request the reports by the file name like so:

ReportPreviewModel model = new ReportPreviewModel();
model.ReportTypeName = "XtraReport1.repx";

previewControl.Model = model;
model.CreateDocument();

I have uploaded a sample that shows how to open any report file from your Silverlight application. Download it here.

Silverlight End User Report Viewer

Silverlight End User Report Viewer

Cheers

Azret

Published Apr 28 2010, 02:50 PM by
Bookmark and Share

Comments

Twitter Trackbacks for Blog: Silverlight Report Viewer and End-User Report Designer ??? v2010 vol 1: In my previous post I have showed you ... [devexpress.com] on Topsy.com

Pingback from  Twitter Trackbacks for                 Blog: Silverlight Report Viewer and End-User Report Designer ??? v2010 vol 1: In my previous post I have showed you ...         [devexpress.com]        on Topsy.com

April 28, 2010 6:00 PM

Silverlight Report Viewer and the XtraReports End User Report … Report Me

Pingback from  Silverlight Report Viewer and the XtraReports End User Report … Report Me

April 29, 2010 12:26 PM
LIVE CHAT

Chat is one of the many ways you can contact members of the DevExpress Team.
We are available Monday-Friday between 7:30am and 4:30pm Pacific Time.

If you need additional product information, write to us at info@devexpress.com or call us at +1 (818) 844-3383

FOLLOW US

DevExpress engineers feature-complete Presentation Controls, IDE Productivity Tools, Business Application Frameworks, and Reporting Systems for Visual Studio, along with high-performance HTML JS Mobile Frameworks for developers targeting iOS, Android and Windows Phone. Whether using WPF, Silverlight, ASP.NET, WinForms, HTML5 or Windows 8, DevExpress tools help you build and deliver your best in the shortest time possible.

Copyright © 1998-2014 Developer Express Inc.
All trademarks or registered trademarks are property of their respective owners