This is a migrated thread and some comments may be shown as answers.

Can I declare a ReportBook in my Razor view using the HTML5 Viewer?

1 Answer 72 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
Scott
Top achievements
Rank 1
Scott asked on 11 Dec 2015, 06:27 PM

I have delivery tickets that I need to print.  The number of these can vary from 1 to 30+.  

I can get an individual report to show fine using this syntax in my MVC view.

@{
    var typeReportSource = new TypeReportSource() { TypeName = "Fasttrak.Reports.CarrierTrakDeliveryTicket, Fasttrak" };
        typeReportSource.Parameters.Add(new Telerik.Reporting.Parameter() { Name = "BOLRecId", Value = 16778 });
}
 
@(Html.TelerikReporting().ReportViewer()
        .Id("reportViewer1")
        .ServiceUrl("/api/reports/")
        .TemplateUrl("/ReportViewer/templates/telerikReportViewerTemplate-9.0.15.324.html")
        .ReportSource(typeReportSource)       
        .ViewMode(ViewModes.INTERACTIVE)
        .ScaleMode(ScaleModes.SPECIFIC)
        .Scale(1.0)
        .PersistSession(false)
)

 

I need to be able to bring up multiples of this report together.  I have tried the following and get "No Report" returned in the viewer.

@{
    var reportBook = new Telerik.Reporting.ReportBook();
     
    var test = Activator.CreateInstance(typeof(Fasttrak.Reports.CarrierTrakDeliveryTicket)) as Telerik.Reporting.Report;
    test.ReportParameters["BOLRecId"].Value = 16778;
    reportBook.Reports.Add(test);
     
    var reportDocument = new Telerik.Reporting.InstanceReportSource();
    reportDocument.ReportDocument = reportBook;
     
}
 
@(Html.TelerikReporting().ReportViewer()
        .Id("reportViewer1")
        .ServiceUrl("/api/reports/")
        .TemplateUrl("/ReportViewer/templates/telerikReportViewerTemplate-9.0.15.324.html")
        .ReportSource(reportDocument)       
        .ViewMode(ViewModes.PRINT_PREVIEW)
        .ScaleMode(ScaleModes.SPECIFIC)
        .Scale(1.0)
        .PersistSession(false)
)

 

This is my ReportsController:

using System.Web;
using Telerik.Reporting.Cache.Interfaces;
using Telerik.Reporting.Services.Engine;
using Telerik.Reporting.Services.WebApi;
 
public class ReportsController : ReportsControllerBase
{
    protected override IReportResolver CreateReportResolver()
    {
        var reportsPath = HttpContext.Current.Server.MapPath("~/Reports");
 
        return new ReportFileResolver(reportsPath)
            .AddFallbackResolver(new ReportTypeResolver());
    }
 
    protected override ICache CreateCache()
    {
        return Telerik.Reporting.Services.Engine.CacheFactory.CreateFileCache();
    }
}

 

Any idea why I'm not seeing the ReportBook in the viewer?  

1 Answer, 1 is accepted

Sort by
0
Stef
Telerik team
answered on 12 Dec 2015, 01:33 PM
Hi Scott,

The HTML5 Viewer is a client-side widget which sends short string descriptions of the resources which the Reporting REST service must resolve and return. Whole data or report objects cannot be serialized and transferred in these requests.

All report's modifications or custom logic for building a report should be executed on the server. In the case of building a ReportBook, you will need to create a custom resolver for the Reporting REST service. From the client you can send string description which will be received by the resolver's Resolve method (the string can include IDs and report names which to be used for creating the ReportBook).
An example of a custom report resolver is illustrated in this forum post.


Regards,
Stef
Telerik
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Feedback Portal and vote to affect the priority of the items
Tags
General Discussions
Asked by
Scott
Top achievements
Rank 1
Answers by
Stef
Telerik team
Share this question
or