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

How do you clear the file export object?

3 Answers 109 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
Steven
Top achievements
Rank 1
Steven asked on 27 Apr 2017, 07:26 PM

I'm having trouble with re-running reports and the export button.  In this scenario, hitting the export button will export all previously opened version of the report, so you end up with multiple exports.  Here's the setup:

Lets say you create a telerik report and you have some kind of a parameter building UI.  You run the report and it opens up below your parameter building section.  Then you decide you want to add one more thing, you add the new parameter and run your report again.  The report correctly loads with the new parameter.

In both runs the report executes on the same element.  On run, it clears the data from the element with the following line of code: myReportData.removeData();.  After which it recreates the report. 

However, when you click "export to pdf", you get a pdf from both versions of the report.  It's as if the binding to that button still exists and the report is cached.  If it is a binding how can I remove it? If the file is caches somewhere, how can I delete that cache?

3 Answers, 1 is accepted

Sort by
0
Stef
Telerik team
answered on 28 Apr 2017, 05:10 PM
Hi Steven,

If you are using a ReportViewer control, please call its RefreshReport method to assure the viewer displays the correct version of the report with the latest changes, before exporting through it.

If you are exporting programmatically, please verify that you are creating a new Report instance for each started export operation. Creating the report instance in the scope of the export method may be better for assuring which report will be exported.


If I am misunderstanding the question, please post a  video illustrating the settings of the application and the problem.

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
Steven
Top achievements
Rank 1
answered on 28 Apr 2017, 05:30 PM

I am using the telerik_ReportViewer and clicking the export button.  All types of export result in the same outcome.

I did eventually find a solution, though maybe there is another way it could be approached.  I was able to debug the telerik code and found that the events were firing twice(or more).  For some reason removing/replacing the report viewer element in html doesn't detach the existing events.  So my remove data call has turned into 3 lines:

var myReportData = $("#reportViewer.k-widget")
myReportData.removeData();
myReportData.unbind();
myReportData.remove();

This seems to remove all traces of the original report and allows the new report viewer to function correctly.  It looked like the refreshReport call didn't allow modification to parameters.  Was I wrong about that?  Is there a better solution than what I found?

0
Stef
Telerik team
answered on 02 May 2017, 11:56 AM
Hi Steven,

The HTML5 Viewer declaration adds a DIV element and jQuery method that creates the viewer object. There is no ready to use method for removing the whole widget from the page.

In case the purpose of the settings is to update the displayed report, you need to create viewer once, where you can use CSS and JS to show/hide the viewer's DIV element. Once the viewer is created you can use its reportsource(rs) method in JavaScript to change the displayed report and/or the parameters sent to the server. There is no need to call refreshReport after setting new values in the viewer's rpeortSource, the viewer will update itself automatically after the change is applied.
For an example, please check to How To: Pass Values to Report Parameters.

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