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

Displaying a dynamically generated Telerik.Reporting.Report

1 Answer 110 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
Gabriel
Top achievements
Rank 1
Gabriel asked on 06 Jul 2015, 09:15 PM

Hello,

I'm currently dynamically generating a Telerik Report in PDF format into a new window by writing the bytes to the response as seen below.

BusinessClass:

 

Telerik.Reporting.Report report = GenerateInspection(formDTO, "DCF", lastSection);
              
Telerik.Reporting.Processing.ReportProcessor processor = new Telerik.Reporting.Processing.ReportProcessor();
              
Telerik.Reporting.InstanceReportSource irs = new Telerik.Reporting.InstanceReportSource();
irs.ReportDocument = report;
  
Telerik.Reporting.Processing.RenderingResult result = processor.RenderReport("PDF", irs, null);
  
return result;

 

 

And in the controller:

 

InspectionRules ir = new InspectionRules(); //my business class
var result = ir.GetReport(id, WebSettings.GetDCFConnectionString, site);
  
this.Response.Clear();
this.Response.ContentType = result.MimeType;
this.Response.Cache.SetCacheability(HttpCacheability.Private);
this.Response.Expires = -1;
this.Response.Buffer = true;
  
this.Response.BinaryWrite(result.DocumentBytes);
this.Response.End();
  
return View();

 

 

This is producing a nice PDF report in a new window.  However requirements now dictate for me to have additional UI elements around and in some case overlayed the report.  My question is what is the best way to go about this?  Do I need the HTML 5 Report Viewer? Is there a simple solution? I must have a portion that on hover overlays a div over the report with controls in it.  Note that in my view/test below the <h1> does not display.  Thanks for any help or suggestions!

My View:

 

@{
    Layout = null;
}
 
<!DOCTYPE html>
 
<html>
<head>
    <meta name="viewport" content="width=device-width" />
    <title>Inspection Report</title>   
</head>
<body>
    <div id="reportViewer1" class="k-widget">
        loading...
    </div>
    <div>
        <h1>THIS IS A TEST</h1>
    </div>
</body>
</html>

 

1 Answer, 1 is accepted

Sort by
0
Gabriel
Top achievements
Rank 1
answered on 07 Jul 2015, 07:23 PM

I was able to achieve this by putting the call to generate the report in an iframe on the page which called a controller action that returns a partial view and writes out the Document to the response same as before.  The answer is always simple after you've found a way.  Here is the updated view in case any need.

 

@{
    Layout = "";
    int reportId = ViewBag.reportId;
    string site = ViewBag.site;
}
 
<!DOCTYPE html>
 
<html>
<head>
    <meta name="viewport" content="width=device-width" />
    <title>Inspection Report</title>
    <script></script>   
</head>
<body>
    <div>
        <h1>THIS IS A TEST</h1>
        <iframe src="/InspectionReport/Report?id=@reportId.ToString()&site=@site" style="width:718px; height:700px;" frameborder="0"></iframe>
    </div>
</body>
</html>

Tags
General Discussions
Asked by
Gabriel
Top achievements
Rank 1
Answers by
Gabriel
Top achievements
Rank 1
Share this question
or