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

Report Rendering - The Operation was Canceled

2 Answers 756 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
Jason
Top achievements
Rank 1
Jason asked on 19 Jul 2011, 08:32 PM
Hi,

I'm running a report viewer in WPF.  My screen has a dropdown list of reports, two datepickers, and a refresh button.  The user selects a report from the dropdown, selects the date range, and hits the refresh button to generate the report.

I have found that when the refresh button is clicked, the report viewer will immediately say "The Operation was Canceled".  This message will last until the report is actually generated.

In the code behind for the refresh button, we take the selected report and give it a data source based on some internal methods to actually put the data together.  Then we set the reportviewer's report to the report that we are generating, and then fire off the RefreshReport method.


Did I miss a step here that is causing this message to show up?  I saw a reference in an old thread to the message and it said that it would be fixed in one of last year's builds.  Any help would be appreciated.

Thanks.

2 Answers, 1 is accepted

Sort by
0
Accepted
Steve
Telerik team
answered on 21 Jul 2011, 01:59 PM
Hi Artel,

There was such a problem in older version of the product (Q2 2010 release) and it has been fixed since. If you're using older version please upgrade. I just tried it with the latest official Q2 2011 release and could not reproduce it.
The RefreshReport method of the WPF viewer you're trying to use would not do what you're trying to accomplish. In fact this method is for internal use only and we have left it public by mistake. Please excuse us for the created confusion due to this.
What you can do is set the Report property to null explicitly and after that assign the correct report again (i.e. this would force the viewer to load the new report).
Another possible approach is to get the ReportViewerModel from the viewer's first child and create an extension method to refresh the report. Here is a sample snippet that illustrates this approach:
Copy Code
Copy Code
Copy Code
public partial class MainPage : UserControl
{
    public MainPage()
    {
        InitializeComponent();
    }
 
    void button1_Click(object sender, RoutedEventArgs e)
    {
        this.ReportViewer1.RefreshTheReport();
    }
}
 
static class ReportViewerExtensions
{
    public static void RefreshTheReport(this ReportViewer reportViewer)
    {
        var layoutRoot = (FrameworkElement)VisualTreeHelper.GetChild(reportViewer, 0);
        var viewerModel = (ReportViewerModel)layoutRoot.DataContext;
        var refreshCommand = viewerModel.RefreshReportCommand;
        if (refreshCommand.CanExecute(null))
        {
            refreshCommand.Execute(null);
        }
    }
}

Hope this helps.

Kind regards,
Steve
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!

0
Jason
Top achievements
Rank 1
answered on 21 Jul 2011, 02:14 PM
Hi Steve,

Setting the report to null and then to the new report fixed the problem immediately.  I have been using the Q1 2011 release which made it all the more baffling as to why this issue was happening.  Everything seems to be good now though, so thank you for your help!
Tags
General Discussions
Asked by
Jason
Top achievements
Rank 1
Answers by
Steve
Telerik team
Jason
Top achievements
Rank 1
Share this question
or