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

Html5 Report Viewer Print Issue on 2nd print

8 Answers 185 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
IamSalik
Top achievements
Rank 1
IamSalik asked on 26 Jun 2015, 12:42 PM

Hello,

I have an issue with print and that is with print command on 2nd time.Here is the simple scenario..
I initialized report viewer of html5. On a button click i refresh report with new data source and added "viewer.commands.print.exec()" for print. It works for the first time. But Second time report is refreshed but is not printed.Here is my Refresh Codeviewer =

$("#reportViewer").data("telerik_ReportViewer");viewer.reportSource({
      report: reportPrms
});
viewer.refreshReport();viewer.commands.print.exec();

What can be the issue. I am using Q3_2014 v 8.2

Regards
Salik

8 Answers, 1 is accepted

Sort by
0
Accepted
Stef
Telerik team
answered on 30 Jun 2015, 02:08 PM
Hello Salik,

On updating the viewer's reportSource, test binding to the viewer's renderingEnd event, which indicates when the report is ready and displayed in the viewer. Then after printing, unbind the event handler, to avoid issues on export or other operations in the viewer.

An example:
function onRenderingEnd() {
           alert('print');
           var viewer = $("#reportViewer1").data("telerik_ReportViewer");
           viewer.commands.print.exec();
           viewer.unbind(telerikReportViewer.Events.RENDERING_END, onRenderingEnd);
       }
$('#btn').click(function () {
           var viewer = $("#reportViewer1").data("telerik_ReportViewer");
           viewer.reportSource({
               report: viewer.reportSource().report,
               parameters: { Parameter1: $('#test').val() }
           });
           viewer.refreshReport();
           viewer.bind(telerikReportViewer.Events.RENDERING_END, onRenderingEnd);           
       });


I hope the provided information is helpful.

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
0
IamSalik
Top achievements
Rank 1
answered on 02 Jul 2015, 07:14 AM

Thanks Stef,

it really worked as required.

0
IamSalik
Top achievements
Rank 1
answered on 06 Jul 2015, 07:43 AM

Hello Steff,

You solution worked but it created another problem. I increases the number of print commands as much as print button is clicked. At 1st click one print is send and dialogue is shown once. But if i cancel the print and click the print button again it shows the dialogue 2 times.

Please tell me how can it be resolved.

Thanks
Regards
Saleem SALIK

0
Stef
Telerik team
answered on 06 Jul 2015, 02:02 PM
Hi Salik,

Please check if the report is not refreshed twice, which will cause the renderingEnd event to fire. Updating the viewer's reportSource will automatically refresh the viewer, the calling refreshReport will refresh the viewer once again.

Test removing the call to the refreshReport method.

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
0
IamSalik
Top achievements
Rank 1
answered on 06 Jan 2017, 11:31 AM

Hello,

I had list of reports to be printed on one button click. What is suddenly started being wrong is that the print dialogue doesn't stops the code from being execute and 2nd report print call closes the first print dialogue, don't have time to send print. 

This issue was actually fix on my previous reply but from few days it has been doing it again. What i have changed in this while is upgraded my kendo.all.min.js but my telerik report versions are same..

Can you please guide me what can be the real cause of this issue?

Regards
Saleem

0
Stef
Telerik team
answered on 09 Jan 2017, 04:31 PM
Hello Saleem,

If you are using custom UI, test using the viewer's printBegin and printEnd events to disable and then re-enable the custom UI that triggers the viewer's print operation.

Regards,
Stef
Telerik by Progress
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
0
IamSalik
Top achievements
Rank 1
answered on 11 Jan 2017, 10:37 AM

Hi Stef,

Couldn't resolve the issue with these events as i already have applied onRenderingEnd event.

I have written the following code according to your previous answer, 

01.PrintAllInQueue: function () {
02.        if (this.PrintQueues.length > 0) {
03.            this.set("PrmJSON", this.PrintQueues[0]);
04.            this.PrintQueues.splice(0, 1);
05.            this.PrintReport();
06.        }
07.        else {
08.            this.set("PrmJSON", "");
09.        }
10.    },
11.    PrintReport: function () {
12.        var viewer = $("#prnReport").data("telerik_ReportViewer");
13.        viewer.reportSource({
14.            report: this.PrmJSON
15.        });
16.        viewer.refreshReport();
17.        if (this.isViewerBinded == false) {
18.            viewer.bind(telerikReportViewer.Events.RENDERING_END, this.onRenderingEnd);
19.            this.set("isViewerBinded", true);
20.        }
21.    },
22.    onRenderingEnd: function () {
23.        //alert('print');
24.        var viewer = $("#prnReport").data("telerik_ReportViewer");
25.        viewer.commands.print.exec();
26.        setTimeout(function () {
27.            PrintAllInQueue();
28.        }, 3000);
29.        //viewer.unbind(telerikReportViewer.Events.RENDERING_END, this.onRenderingEnd);
30.    }

 

which is supposed to stop execution at line 25 until print dialogue is closed (was working for a long time) but it continues and refreshes viewer for new report. No clue why?.

Regards
Salik

0
Stef
Telerik team
answered on 12 Jan 2017, 05:33 PM
Hi Salik,

At line 25, you are invoking the print command of the viewer. The viewer is not aware about the user's choice to print or to close the  Print dialog, as it is out of the scope of the Reporting engine. The Print dialog belongs to the browser's PDF plugin that handles the PDF file delivered by the Reporting REST Service to the client. You have a timeout after calling the print command, that can slow down consecutive operations.

If you are using the viewer only to print a report, not to display it, please consider the approach from Print a report directly at client-side without displaying it in a Viewer.

Regards,
Stef
Telerik by Progress
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
IamSalik
Top achievements
Rank 1
Answers by
Stef
Telerik team
IamSalik
Top achievements
Rank 1
Share this question
or