I am using the Telerik Reporting REST Service project to render code-based reports in the WinForms ReportViewer. But I have a problem with this "PREVIEW" button, when the user quickly clicks multiple times while generating the Report. It throws the following exception within the viewer:
I just want to disable the Preview button while the report is still generating, and enable it once the report is fully generated. And I don't want to allow the user to double-click the PREVIEW button(Disable the button immediately on a first click until the report is fully generated).
Please help me fix my issue.
Thanks in advance.
3 Answers, 1 is accepted
Hi Sathish,
The Preview button is a part of the ParametersArea which can be hidden with the ParametersAreaVisible property. Therefore, to hide the button only when a Report is Rendering, you can use the RenderingBegin and RenderingEnd events of the Viewer to change the value of the ParametersAreaVisible property. For example:
private void RenderingBegin(object sender, Telerik.ReportViewer.Common.RenderingBeginEventArgs args)
{
// Hide the Parameter Area which contains the Preview button
this.reportViewer.ParametersAreaVisible = false;
}
private void RenderingEnd(object sender, Telerik.ReportViewer.Common.RenderingEndEventArgs args)
{
// Show the Parameter Area
this.reportViewer.ParametersAreaVisible = true;
}
Regards,
Justin
Progress Telerik
Love the Telerik and Kendo UI products and believe more people should try them? Invite a fellow developer to become a Progress customer and each of you can get a $50 Amazon gift voucher.
I am already aware of this. I have a problem here also.
Assume that there is a report with data around 100k. Then the report will take some time to load all the pages. After loading all the pages, "RenderingEnd" will hit.
1. What I expect is that, once the report is generated, the Preview button should be enabled immediately (without waiting for all the pages to load). Again, if the user clicks on 'Preview', the report should reload with the selected parameters.
----OR----
2. After each Preview button click, block another quick click. Because the report is rendering fine for multiple clicks if the user is given gaps of 2-3 seconds for each click. The only problem is clicking quickly(Without a gap) on the Preview button.
Please suggest a solution. I would like to go for the 2 option.
Ah.. I found the exact real root cause.
When I click Preview again with the same parameters, only an error occurs.
Please suggest a solution for this issue.
Thank you.
Hello Sathish,
To address option 2 :
You can insert a pause of an arbitrary about of time in the RenderingBegin event. After the time elapses, set the ParametersAreaVisible to true again. Something like this:
private async void RenderingBegin(object sender, Telerik.ReportViewer.Common.RenderingBeginEventArgs args)
{
// Hide the Parameter Area which contains the Preview button
this.reportViewer.ParametersAreaVisible = false;
// Delay an amount of time
await Task.Delay(2000);
// Display the Parameter Area
this.reportViewer.ParametersAreaVisible = true;
}
If rendering twice in a row with the same parameters is the issue, you can store the parameters and check to see if new ones have been selected. If they are the same as the stored values, cancel the rendering. This is custom logic that you will need to write. The current parameters can be accessed in the RenderingBegin like this:
_currentParameters = this.reportViewer.ReportSource.Parameters;
And the rendering can be canceled like this:
args.Cancel = true;
I hope this helps.
Regards,
Justin
Progress Telerik
Love the Telerik and Kendo UI products and believe more people should try them? Invite a fellow developer to become a Progress customer and each of you can get a $50 Amazon gift voucher.
Hi Justin,
I found the root cause.
The main issue is that if you click again on the preview button with the same parameters(that are already in generating state), it will display that error in the viewer.
This can be fixed. Please suggest a solution.
Thank you
Hello Sathish,
I see that you suspect the root cause is the rapid selection of the preview button with the same parameters.
The proposed solutions are still valid and could be adjusted if you like. For example:
You don't need to hide the Preview button. Instead create a Flag, based on either a timer, or whether or not the parameters are indeed the same as they were when the rendering last began. Then, either cancel rendering or do not based on the Flag.
If further assistance is required, please share which of these solutions did not work for you. You may also consider creating a support ticket and sharing a log created by following the steps described in How to troubleshoot errors in ASP.NET Core projects - Telerik Reporting.
I hope one of the proposed solutions helps.
Regards,
Justin
Progress Telerik
Love the Telerik and Kendo UI products and believe more people should try them? Invite a fellow developer to become a Progress customer and each of you can get a $50 Amazon gift voucher.