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

Using PrintReport on a separated file.

1 Answer 95 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
Kira
Top achievements
Rank 1
Kira asked on 31 Oct 2011, 09:07 PM
Hi!

I'm using the following code to export my report to PDF (and it works fine for me):

ReportViewer.prototype.PrintReport = function () {
     this.ExportReport("PDF");
}

But only works if I put the code after the declaration of the ReportViewer. But now I need this to be global to my project. Is there a way of  do a similar functionality putting this code on a separated file?

Regards!

1 Answer, 1 is accepted

Sort by
0
Steve
Telerik team
answered on 01 Nov 2011, 09:41 AM
Hi Kira,

The Client-Side API should be used after the report viewer control is properly initialized and that is why it is used after the report viewer declaration. Generally you do not have to explicitly use the ExportReport method inside of PrintReport function and you can utilize such code as long as you make sure the report viewer has been initialized and in your case you also need to make sure that the report is loaded in the viewer:

<script type="text/javascript">
                ReportViewer.OnReportLoadedOld = ReportViewer.OnReportLoaded;
                ReportViewer.prototype.OnReportLoaded = function () {
                    this.OnReportLoadedOld();
                    this.ExportReport("PDF");
                }
      </script>

Greetings,
Steve
the Telerik team

Q2’11 SP1 of Telerik Reporting is available for download (see what's new). Get it today.

Tags
General Discussions
Asked by
Kira
Top achievements
Rank 1
Answers by
Steve
Telerik team
Share this question
or