Hello,
From the documentation, it doesn't seem hard to create a report programmatically:
However, After I have the report created, how do I view it using the MVC report viewer (which I already have set up). Are there some additional properties I need to set? Ideally, I thought I could just pass the entire Report object to the view and into the viewer, but there is no overlord for that. So once I have the report created programmatically (I have to do this for reasons beyond this thread), how I can view it in the report viewer?
From the documentation, it doesn't seem hard to create a report programmatically:
Telerik.Reporting.Report report = new Telerik.Reporting.Report(); string sql = @"SELECT * FROM Recipient"; string connectionString = "Data Source=EVAN-PC\\SQLEXPRESS;Initial Catalog=AccufloMaster;Integrated Security=True;User ID=sa;Password=creative"; System.Data.SqlClient.SqlDataAdapter adapter = new System.Data.SqlClient.SqlDataAdapter(sql, connectionString); report.DataSource = adapter; report.Name = "recipientReport"; return View(report);However, After I have the report created, how do I view it using the MVC report viewer (which I already have set up). Are there some additional properties I need to set? Ideally, I thought I could just pass the entire Report object to the view and into the viewer, but there is no overlord for that. So once I have the report created programmatically (I have to do this for reasons beyond this thread), how I can view it in the report viewer?
@model Telerik.Reporting.Report@using Telerik.Reporting.Examples.CSharp@{ ViewBag.Title = "Telerik HTML5 Report Viewer MVC Demo";}@section styles{ <link href="http://netdna.bootstrapcdn.com/font-awesome/3.2.1/css/font-awesome.css" rel="stylesheet" /> <link href="http://cdn.kendostatic.com/2013.2.918/styles/kendo.common.min.css" rel="stylesheet" /> <link href="http://cdn.kendostatic.com/2013.2.918/styles/kendo.blueopal.min.css" rel="stylesheet" /> <style> #reportViewer1 { position: absolute; left: 5px; right: 5px; top: 5px; bottom: 5px; overflow: hidden; font-family: Verdana, Arial; } </style> <link href="@Url.Content("~/ReportViewer/styles/telerikReportViewer-8.1.14.804.css")" rel="stylesheet" />}@{ var typeReportSource = new TypeReportSource() { TypeName = typeof(ReportCatalog).AssemblyQualifiedName }; // typeReportSource.Parameters.Add("OrderNumber", Model.SelectedInvoice); //ReportSource(new UriReportSource() { Uri = "Product Catalog.trdx" })}@(Html.TelerikReporting().ReportViewer() // Each report viewer must have an id - it will be used by the initialization script // to find the element and initialize the report viewer. .Id("reportViewer1") // The url of the service which will provide the report viewer with reports. // The service must be properly configured so that the report viewer can // successfully communicate with the server. // For more information on how to configure the service please check http://www.telerik.com/help/reporting/telerik-reporting-rest-conception.html. .ServiceUrl(Url.Content("~/api/reports/")) // The url for the report viewer template. The template can be edited - // new functionalities can be added and unneeded ones can be removed. // For more information please check http://www.telerik.com/help/reporting/html5-report-viewer-templates.html. .TemplateUrl(Url.Content("~/ReportViewer/templates/telerikReportViewerTemplate-8.1.14.804.html")) // Strongly typed ReportSource - TypeReportSource or UriReportSource. .ReportSource(Model.Name) // Specifies whether the viewer is in interactive or print preview mode. // PRINT_PREVIEW - Displays the paginated report as if it is printed on paper. Interactivity is not enabled. // INTERACTIVE - Displays the report in its original width and height witn no paging. Additionally interactivity is enabled. .ViewMode(ViewModes.PRINT_PREVIEW) // Sets the scale mode of the viewer. // Three modes exist currently: // FIT_PAGE - The whole report will fit on the page (will zoom in or out), regardless of its width and height. // FIT_PAGE_WIDTH - The report will be zoomed in or out so that the width of the screen and the width of the report match. // SPECIFIC - Uses the scale to zoom in and out the report. .ScaleMode(ScaleModes.SPECIFIC) // Zoom in and out the report using the scale // 1.0 is equal to 100%, i.e. the original size of the report .Scale(1.0) // Sets whether the viewer’s client session to be persisted between the page’s refreshes(ex. postback). // The session is stored in the browser’s sessionStorage and is available for the duration of the page session. .PersistSession(false) // Sets the print mode of the viewer. .PrintMode(PrintMode.AutoSelect))@section scripts{ <!--kendo.all.min.js can be used as well instead of kendo.web.min.js and kendo.mobile.min.js--> <script src="@Url.Content("~/ReportViewer/js/telerikReportViewer-8.1.14.804.js")"></script> <script src="http://cdn.kendostatic.com/2013.2.918/js/kendo.web.min.js"></script> <!--kendo.mobile.min.js - optional, if gestures/touch support is required--> <script src="http://cdn.kendostatic.com/2013.2.918/js/kendo.mobile.min.js"></script>}