cancel
Showing results for 
Search instead for 
Did you mean: 

Control the / interact with Report Viewer via Javascript

former_member364076
Participant
0 Kudos

Hi

i have some questions about client control of the report viewer. I would want to use some custom buttons in order to use the report viewer functionalities, as an example to print, or to known when a customer leaf through the report pages saving something in a javascript variable.

Is it possible to interact with the report viewer? There is a reference text?

Thanks

Accepted Solutions (1)

Accepted Solutions (1)

former_member208657
Active Contributor
0 Kudos

I've never done it with JavaScript, but you could use the built in events to keep track of some information about report navigation. Some of the available events are below.

CrystalReportViewer Events

Description

CrystalReportViewerBase.AfterRender Event

(Inherited from CrystalReportViewerBase Class.) Event fires when the report rendering process is finished.

CrystalReportViewerBase.AfterRenderContent Event

(Inherited from CrystalReportViewerBase Class.) Event fires when the report content rendering process is finished.

CrystalReportViewerBase.AfterRenderObject Event

(Inherited from CrystalReportViewerBase Class.) Event fires when the report object rendering process is finished.

CrystalReportViewerBase.BeforeRender Event

(Inherited from CrystalReportViewerBase Class.) Event fires when the report rendering process starts.

CrystalReportViewerBase.BeforeRenderContent Event

(Inherited from CrystalReportViewerBase Class.) Event fires when the report content rendering process starts.

CrystalReportViewerBase.BeforeRenderObject Event

(Inherited from CrystalReportViewerBase Class.) Event fires when the report object rendering process starts.

CrystalReportViewer.Drill Event

Event fires when a report is drilled down on.

CrystalReportViewer.DrillDownSubreport Event

Event fires when the user drills down on a subreport.

CrystalReportViewerBase.Error Event

(Inherited from CrystalReportViewerBase Class.) Event fires when the report object throws an exception.

CrystalReportViewer.Navigate Event

Event fires when the user navigates through a report.

CrystalReportViewerBase.OnRenderScript Event

(Inherited from CrystalReportViewerBase Class.) Event fires when the HTML script generation starts.

CrystalReportViewerBase.OnRenderStyle Event

(Inherited from CrystalReportViewerBase Class.) Event fires when the HTML style class generation starts.

CrystalReportViewerBase.ReportPartBookmarkNavigation Event

(Inherited from CrystalReportViewerBase Class.) Event fires after navigation to a report part in the same report or another report is finished.

CrystalReportViewer.ReportRefresh Event

Event fires when the data in the report is refreshed.

CrystalReportViewer.Search Event

Event fires when text is searched for in the report.

CrystalReportViewer.ViewZoom Event

Event fires when zoom level of the viewer changes.

CrystalReportViewerBase Events

Description

CrystalReportViewerBase.AfterRender Event

Event fires when the report rendering process is finished.

CrystalReportViewerBase.AfterRenderContent Event

Event fires when the report content rendering process is finished.

CrystalReportViewerBase.AfterRenderObject Event

Event fires when the report object rendering process is finished.

CrystalReportViewerBase.BeforeRender Event

Event fires when the report rendering process starts.

CrystalReportViewerBase.BeforeRenderContent Event

Event fires when the report content rendering process starts.

CrystalReportViewerBase.BeforeRenderObject Event

Event fires when the report object rendering process starts.

CrystalReportViewerBase.Error Event

Event fires when the report object throws an exception.

CrystalReportViewerBase.OnRenderScript Event

Event fires when the HTML script generation starts.

CrystalReportViewerBase.OnRenderStyle Event

Event fires when the HTML style class generation starts.

CrystalReportViewerBase.ReportPartBookmarkNavigation Event

Event fires after navigation to a report part in the same report or another report is finished.

former_member364076
Participant
0 Kudos

i don't understand how i could use these events for my purposes..

i've tried to understand more of viewer js scripts but is too hard,

functions maybe are in allInOne.js which use MochiKit 1.4 but i don't know how to continue..

former_member208657
Active Contributor
0 Kudos

One of my first questions is "Why are you trying to do this? What business problem are you attempting to solve by adding this type of tracking?"

You can accomplish your goal with paging through the report by using the Navigate event. As for the Print button, I don't think we have an event for that so it would be more difficult.

We don't have any public API for the JavaScript we use. It has gotten more and more complex over the years as we've added more features to the viewer. You found that we use MochiKit in the back end. Your best bet is to explore the events we've exposed for the viewer.

If you don't find one that you need I suggest you visit the [Idea Place|http://www.sdn.sap.com/irj/scn/idea-place] and submit your suggestion. Of course, search to see if anyone else has submitted it first though.

former_member364076
Participant
0 Kudos

i would to make a button that via javascript recall the details page (previuos than report page) through history.go() but the matter is calculate the number of steps

i would to create an export button that make only a pdf, not opening a UI with many choices

former_member208657
Active Contributor
0 Kudos

You shouldn't be using the History or the Back button in ASP.NET web applications. As a developer it is your job to create the navigation experience using .NET controls like - buttons, .NET hyperlinks, etc.

There is lots of code on the forums and knowledge base on how to export a report to PDF. The methods you want to look at are Export() and ExportToHttp(). You could easily call these from a Click event on a button you add to a web form. Stay away from just using JavaScript if you can.

former_member364076
Participant
0 Kudos

uh? the sound of your post is strange, i need to know how use javascript for my purposes (in a web 2.x) and you tell me avoid javascript? and why CRViewer is based on it?

former_member208657
Active Contributor
0 Kudos

The CrystalReportViewer control isn't solely based on JavaScript. It is a .NET control we created to allow you to view Crystal Reports in a web browser. Like all .NET controls it is comprised of .NET components plus JavaScript embedded in the HTML source page.

If you want to use the CrystalReportViewer you need to use the properties and methods exposed via the SDK. We never designed the control to be accessed directly with JavaScript.

Please read the documentation on how to use the viewer if you have any further questions.

Answers (0)