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

Notification for when report is done rendering

2 Answers 327 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
Christopher Achille
Top achievements
Rank 1
Christopher Achille asked on 29 Jun 2010, 07:04 PM
  Is there a way to know when a report is done being rendered in the Wpf.ReportViewer?

  We are launching a viewer and then a report within the viewer, and want a way to be able to control when a user has the ability to change the report within the viewer.  We don't want them to be able to change it while it is rendering, but after it is completed we are happy with them loading a new report.

  I do not see any such events/notification on Wpf.ReportViewer.  Is there any other way to know this type of thing.

  Also, depending on the timing of replacing the Report property in Wpf.ReportViewer, I will sometimes get a "The operation was cancelled." message while the report is loading instead of the nice "Rendering Report..." progress bar.  (Even though the report does still load after it is completed.)  Is this a know problem, am I doing something wrong?  I can get it just by click the Refresh button a little too much.

Thanks.

2 Answers, 1 is accepted

Sort by
0
Steve
Telerik team
answered on 01 Jul 2010, 02:36 PM
Hi Christopher,

You can use the IsInProgress property of the ReportViewerModel. I've attached an example that shows the functionality at hand.
As for your second inquiry - indeed this is a known issue that would be fixed for the upcoming Q2 release in mid-July.

Best wishes,
Steve
the Telerik team
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 Public Issue Tracking system and vote to affect the priority of the items
0
Christopher Achille
Top achievements
Rank 1
answered on 07 Jul 2010, 07:23 AM
Steve,
  Thank you very much, that worked great.

  I took your code, and made a couple changes that worked better for what we were doing.  Below is my wrapper helper class which inherits from the Wpf.ReportViewer, and then exposes the two notifications.  One for Rendering starting, and one for Rendering completing.  Hopefully someone will find it useful.

Thanks,
  Chris

 

using System;  
using System.Collections.Generic;  
using System.ComponentModel;  
using System.Linq;  
using System.Text;  
using System.Threading;  
using Telerik.Reporting;  
using Telerik.ReportViewer.Wpf;  
 
namespace xx  
{  
    /// <summary>  
    /// Wrapper class WpfReportViewer which supports notification for   
    /// when rendering has started, and then completed.  
    /// </summary>  
    public class HcxWpfReportViewer : ReportViewer  
    {  
        private event EventHandler _notificationRenderingStarted;  
        private event EventHandler _notificationRenderingCompleted;  
        private Report             _report;  
 
        /// <summary>  
        /// Constructor  
        /// </summary>  
        public HcxWpfReportViewer()  
        {  
            _notificationRenderingStarted   = null;  
            _notificationRenderingCompleted = null;  
            _report                         = null;  
 
            RVModel.PropertyChanged +=  
                new PropertyChangedEventHandler( viewerModel_PropertyChanged );  
        }  
 
        /// <summary>  
        /// Set the report for the viewer  
        /// </summary>  
        public new Report Report  
        {  
            set 
            {  
                _report = value;  
 
                base.Report = value;  
            }  
        }  
 
        /// <summary>  
        /// Notification that the particular property has changed  
        /// </summary>  
        /// <param name="sender"></param>  
        /// <param name="e"></param>  
        private void viewerModel_PropertyChanged( object sender, PropertyChangedEventArgs e )  
        {  
            if ( this.Dispatcher.Thread == Thread.CurrentThread )  
            {  
                switch ( e.PropertyName )  
                {  
                    case "IsInProgress":  
 
                        if ( RVModel.IsInProgress )  
                        {  
                            if ( _notificationRenderingStarted != null )  
                            {  
                                _notificationRenderingStarted( _report, new EventArgs() );  
                            }  
                        }  
                        else 
                        {  
                            if ( _notificationRenderingStarted != null )  
                            {  
                                _notificationRenderingCompleted( _report, new EventArgs() );  
                            }  
                        }  
 
                        break;  
                }  
            }  
            else 
            {  
                this.Dispatcher.Invoke( new PropertyChangedEventHandler( viewerModel_PropertyChanged ),  
                                        new object[] { sender, e } );  
            }  
        }  
 
        /// <summary>  
        /// Get the report viewer model for this report...  
        /// </summary>  
        private ReportViewerModel RVModel  
        {  
            get 
            {  
                return (ReportViewerModel) this.DataContext;  
            }  
        }  
 
        /// <summary>  
        /// Notification that rendering of the report has started.  
        /// </summary>  
        public event EventHandler RenderingStarted  
        {  
            add  
            {  
                _notificationRenderingStarted += value;  
            }  
            remove  
            {  
                _notificationRenderingStarted -= value;  
            }  
        }  
 
        /// <summary>  
        /// Notification that rendering of the report has completed.  
        /// </summary>  
        public event EventHandler RenderingCompleted  
        {  
            add  
            {  
                _notificationRenderingCompleted += value;  
            }  
            remove  
            {  
                _notificationRenderingCompleted -= value;  
            }  
        }  
      
    }  
}  
 
Tags
General Discussions
Asked by
Christopher Achille
Top achievements
Rank 1
Answers by
Steve
Telerik team
Christopher Achille
Top achievements
Rank 1
Share this question
or