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

PDF File Generation & Hourglass

7 Answers 113 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
Barry
Top achievements
Rank 1
Barry asked on 10 Feb 2008, 09:39 PM
I ran into a technical roadblock and wonder if anyone has a solution or suggestions.  Scenario and background as follows:

1.  I'm using Telerik Reporting to generate a number of reports in a web site (built with ASP .Net 2.0) .  I'm not using the report viewer, rather the report is streamed to the user as PDF files from which they can print or save as appropriate.  This is accomplished via the following code sequence (pretty standard technique I believe):

Response.Clear()
Response.ContentType = strMimeType
Response.Cache.SetCacheability(HttpCacheability.Private)
Response.Expires = -1
Response.Buffer =

False
Response.AddHeader("content-disposition", _
"attachment; filename=""" & strFileName & """")
Response.OutputStream.Write(reportBytes, 0, reportBytes.Length)
Response.End()



2.  From the report web page, the user clicks the Generate button to generate a selected report.  As soon as this button is clicked, the mouse cursor turns to an hourglass.  This is accomplished via a simple client-side javascript function that sets the cursor style to hourglass in conjunction with setting the "onClick" attribute for the button Generate, (in page_load event), as follows:

function hourglass()
{document.body.style.cursor =
"wait";}


' This is set in the page_load event of the aspx.vb file
btnGenerate.Attributes("onclick") = "javascript: hourglass();"


3.  In real time, the user clicks the Generate button, the mouse cursor turns to hourglass (by virtue of the client-side action mentioned above) while the report is being generated.  After a period of time, the PDF download dialog appears on top of the report web page.  The user opens the PDF file, prints it and then closes the PDF file.  Everthing works fine up to this point.

4.  Once the PDF file is closed, the report web page is, of course, still there.  The problem is the mouse cursor is still showing the hourglass.

5.  The problem appears to lie in the fact that the cursor is never reset to the default style.  And it appears that there isn't an opportunity to reset the cursor because there isn't a postback to the report web page AFTER the user has printed the PDF file and closes the PDF application. 

I've tried adding client-side javascript to reset the cursor at window.onload.  It doesn't do it because the report web page is NOT reloaded after the PDF file is generated.

I hope this makes sense.  I'd appreciate if anyone has any suggestions.

Thanks.

Barry


 

7 Answers, 1 is accepted

Sort by
0
Chavdar
Telerik team
answered on 11 Feb 2008, 03:25 PM
Hi Barry,

There is no convenient way to detect when the PDF document has been closed in order to change the cursor back to normal. However, you can try something different. You can handle the onfocus event of the window and reset the cursor there. Here is an example:

<head>
    ...
        <script type="text/javascript">
            function hourglass()
            {
                document.body.style.cursor= "wait";             
            }
       
            function resetCursor()
            {           
                document.body.style.cursor= "default";
            }              
        </script>
    ...
</head>

<form ...>
        ...
        <script type="text/javascript">
                window.onfocus = resetCursor;
        </script>
       ...
</form>

This is not an ideal solution but I hope it can help.

Sincerely yours,
Chavdar
the Telerik team

Instantly find answers to your questions at the new Telerik Support Center
0
Barry
Top achievements
Rank 1
answered on 12 Feb 2008, 07:08 AM
Hi Chavdar,

Thank you very much for answering my post with your suggestions. I will try it shortly and let you know if it helps.

Thanks again.

Barry
0
Barry
Top achievements
Rank 1
answered on 15 Feb 2008, 11:35 PM
Hi Chavdar,

I'd like to follow up and let you know that your suggestion of resetting the cursor at the window.onfocus event works nicely.  Well, that's probably as good as we can get since there is no way to detect the closing of the PDF file.

Thank you very much for your help.

Barry
0
Augusto Cosatti
Top achievements
Rank 1
answered on 17 Nov 2010, 12:58 PM
Hello.

Is there a way to display the Hourglass cursor while the Report Viewer is loading data and preparing the output on the web page? The the cursor would automatically set back to Default.

I have a report that returns a lot of data and it takes around 10 seconds for the first page to display. I would to have an hourglass or a wheel while the user is waiting.

Thanks for you answer
Augusto
0
Steve
Telerik team
answered on 18 Nov 2010, 05:59 PM
Hi Augusto,

The report viewer has its own loading panel, which is showing while the report is being generated. You can see this in action in our online examples e.g. Report Book demo.

Regards,
Steve
the Telerik team

Instantly find answers to your questions at the new Telerik Support Center
0
Augusto Cosatti
Top achievements
Rank 1
answered on 18 Nov 2010, 06:07 PM

Hi Steve.

Thanks for your reply.
Actually the loading panel comes up but less than half a second. Same problem when I click on the Refresh button.

What am I doing wrong?

Thanks
Regards
Augusto

The aspx code is

<%@ Page Language="C#" AutoEventWireup="true" CodeFile="ShowReport.aspx.cs" Inherits="ITChargeback.ShowReport" %>
  
<%--<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">--%>
  
<head id="Head1" runat="server">
    <title></title>
    <style type="text/css">   
    form#form1, div#content
    
        height: 100%;
    }
    </style>
</head>
<body>
    <form id="form1" runat="server">
        <div id="content">
            <telerik:ReportViewer ID="ReportViewer" runat="server" Height="99%" Width="100%">
            </telerik:ReportViewer>
        </div>
    </form>
</body>
</html>

and the code behind is
Report rpt = (Report)this.Session["ShowReport"];

// Run report
this.ReportViewer.ShowPrintButton = false;
this.ReportViewer.ShowZoomSelect = true;
this.ReportViewer.ShowHistoryButtons = false;
this.ReportViewer.ZoomMode = Telerik.ReportViewer.WebForms.ZoomMode.PageWidth;
this.ReportViewer.ShowParametersButton = true;
this.ReportViewer.Report = rpt;
0
Steve
Telerik team
answered on 19 Nov 2010, 09:10 AM
Hello Augusto,

There was a problem with the loading panel in the Q2 SP1 release, which we addressed in Q3. Please upgrade and it should work as expected.

Sorry for the confusion that this caused.

Greetings,
Steve
the Telerik team
Get started with Telerik Reporting with numerous videos and detailed documentation.
Tags
General Discussions
Asked by
Barry
Top achievements
Rank 1
Answers by
Chavdar
Telerik team
Barry
Top achievements
Rank 1
Augusto Cosatti
Top achievements
Rank 1
Steve
Telerik team
Share this question
or