Capture toolbar print button event on Web Report Viewer?

11 posts, 0 answers
  1. Warren
    Warren avatar
    24 posts
    Member since:
    May 2008

    Posted 14 Jul 2011 Link to this post

    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. :)
  2. Peter
    Admin
    Peter avatar
    1611 posts

    Posted 14 Jul 2011 Link to this post

    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!

  3. DevCraft banner
  4. Warren
    Warren avatar
    24 posts
    Member since:
    May 2008

    Posted 14 Jul 2011 Link to this post

    Thanks Telerik, will give it a try!
  5. Warren
    Warren avatar
    24 posts
    Member since:
    May 2008

    Posted 14 Jul 2011 Link to this post

    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
  6. Peter
    Admin
    Peter avatar
    1611 posts

    Posted 18 Jul 2011 Link to this post

    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!

  7. Kishore
    Kishore avatar
    5 posts
    Member since:
    Jul 2011

    Posted 01 Oct 2011 Link to this post

    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.
  8. Vijetha
    Vijetha avatar
    9 posts
    Member since:
    Jul 2011

    Posted 03 Oct 2011 Link to this post

    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
  9. Steve
    Admin
    Steve avatar
    10941 posts

    Posted 04 Oct 2011 Link to this post

    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 >>

  10. CHEN
    CHEN avatar
    4 posts
    Member since:
    Jul 2011

    Posted 31 Dec 2011 Link to this post

    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!
  11. CHEN
    CHEN avatar
    4 posts
    Member since:
    Jul 2011

    Posted 31 Dec 2011 Link to this post

    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!
  12. Steve
    Admin
    Steve avatar
    10941 posts

    Posted 04 Jan 2012 Link to this post

    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!

Back to Top
DevCraft banner