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

Capture toolbar print button event on Web Report Viewer?

10 Answers 415 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
Warren
Top achievements
Rank 2
Warren asked on 14 Jul 2011, 07:07 AM
Hey guys,

I am using the Telerik Web Report viewer on a webform and have the "ShowPrintButton" enabled. Is there any way to capture when the print button is pressed on either client-side or in the code behind? I know I can add a print button and trigger the print using the client-side API but rather use the default print button on the toolbar.

Any suggestions will help, thanks. :)

10 Answers, 1 is accepted

Sort by
0
Peter
Telerik team
answered on 14 Jul 2011, 03:13 PM
Hi Warren Reinke,

If you want to keep the default print button our suggestion is to create a class that derives from Telerik.Reporting.Report and attach to Report.ItemDataBinding. This way you will be able to check the query string for the print action as shown in the following code snippet:

public class CustomReports:Report
{
    public string Name{get; set;}
 
    public CustomReports()
        : base()
    {
        this.ItemDataBinding += new System.EventHandler(CustomReports_ItemDataBinding);
    }
 
    void CustomReports_ItemDataBinding(object sender, System.EventArgs e)
    {
        var queryString = System.Web.HttpContext.Current.Request.QueryString;
 
        if (string.Compare(queryString["optype"],
            "Print",
            System.StringComparison.InvariantCultureIgnoreCase) == 0)
        {
            //TO DO before report is printing
        }
    }
}
You can use this class as base class for your reports, this way you can reuse the print verification code. Regards,
Peter
the Telerik team

Register for the Q2 2011 What's New Webinar Week. Mark your calendar for the week starting July 18th and book your seat for a walk through of all the exciting stuff we will ship with the new release!

0
Warren
Top achievements
Rank 2
answered on 14 Jul 2011, 05:58 PM
Thanks Telerik, will give it a try!
0
Warren
Top achievements
Rank 2
answered on 14 Jul 2011, 10:39 PM
Hey Peter, 

From what I see, the Telerik.ReportViewer.WebForms.ReportViewer does have a DataBinding event and I can capture that on the code behind without having to inherit from Telerik.Reporting.Report. However, this databind seems to only occur when the report loads. Any toolbar print or export event does not trigger the databind again. Any suggestions or am I missing something?

Thanks for the help
0
Peter
Telerik team
answered on 18 Jul 2011, 04:45 PM
Hello Warren,

The Web report viewer doesn't fire any events on print.

Greetings,
Peter
the Telerik team

Register for the Q2 2011 What's New Webinar Week. Mark your calendar for the week starting July 18th and book your seat for a walk through of all the exciting stuff we will ship with the new release!

0
Kishore
Top achievements
Rank 1
answered on 01 Oct 2011, 11:53 AM
Hi

I am new bie to telerik reports, we are using telerik reports in one of our projects where I need to show the Progress bar till the report ui is updated. Now the report viewer inbuilt progress bar is closed once the report data is loaded. Please guide me.
0
Vijetha
Top achievements
Rank 1
answered on 03 Oct 2011, 03:14 PM
Hi ,

We are using telerik reports in our project. Telerik ReportViewer is provided with In built progress bar  'Rendering Report' and 'Loading Page' while showing reports . But here i want to use my own customized ProgressBar by hiding the default one which is provided by reportViewer.

Version of the Product we are using :Reporting Q2 2011
0
Steve
Telerik team
answered on 04 Oct 2011, 10:14 AM
Hi guys,

@Kishore: there is no out of the box functionality for what you ask for, but this is logged as feature request for all the viewers. If you're using the web report viewer, we can offer the following solution:
Copy Code
<telerik:ReportViewer runat="server" id="ReportViewer1" Height="570px"
            Width="780px"></telerik:ReportViewer>   
        <asp:Label runat="server" ID="Label1"></asp:Label>
         <script type="text/javascript">
            var viewer1 = <%= ReportViewer1.ClientID %>;
            viewer1.OnPrintReportLoadedOriginal = viewer1.OnPrintReportLoaded;
             
            viewer1.OnPrint = function()
            {
                UpdateStatusLabel("Preparing the report to print....");
                this.PrintReport();
            };
             
            viewer1.OnPrintReportLoaded = function()
            {
                viewer1.OnPrintReportLoadedOriginal();
                UpdateStatusLabel("");
            }  
             
            function UpdateStatusLabel(msg)
            {
                var label = document.getElementById('<%=Label1.ClientID %>');
                label.innerHTML = msg;
            }                 
             
         </script>

Further you can customize the script to show or hide an animated image or implement any other way of displaying the print progress. Hope it helps.

@Vijetha: If you are using the web report viewer, review Applying custom skin to the web report viewer code library. If you are using the WPF or Silverlight viewers, you can edit their templates as described in Creating Style in Expression Blend.

Kind regards,
Steve
the Telerik team

Explore the entire Telerik portfolio by downloading the Ultimate Collection trial package. Get it now >>

0
CHEN
Top achievements
Rank 1
answered on 31 Dec 2011, 07:58 AM
Why the new internal build 1222 not work?
I can't capture the print event!
but the code is the same , why the trial version works but the paid one is not????
I am very disappointment!
0
CHEN
Top achievements
Rank 1
answered on 31 Dec 2011, 02:01 PM
The newly internal build 1222 doesn't work for this solution.
When I use the CustomReport, trial version works well, but the paid one is not!
I hope you can help me figure it out!
Thank you!
0
Steve
Telerik team
answered on 04 Jan 2012, 02:21 PM
Hi CHEN,

We've just tried the provided code with the latest internal build 5.3.11.1222 and it works as expected. Copy-paste the provided solution in clean aspx page to make sure nothing interferes with the code execution. Additionally the trial versions of all Telerik products are fully functional and will work for an unlimited time but with a copyright message displayed on each report page, so the same code would work independently of whether you're using dev or trial version.

Kind regards,
Steve
the Telerik team

Q3’11 of Telerik Reporting is available for download. Register for the What's New in Data Tools webinar to see what's new and get a chance to WIN A FREE LICENSE!

Tags
General Discussions
Asked by
Warren
Top achievements
Rank 2
Answers by
Peter
Telerik team
Warren
Top achievements
Rank 2
Kishore
Top achievements
Rank 1
Vijetha
Top achievements
Rank 1
Steve
Telerik team
CHEN
Top achievements
Rank 1
Share this question
or