Starting in 2019, the Reporting control is no longer included in Essential Studio®. If you're experiencing issues with the Syncfusion� Reporting Platform, Report Viewer, Report Designer, or Report Writer, we recommend migrating to Bold Reports, our dedicated reporting platform.

Bold Reports offers a comprehensive suite of tools and features for all your reporting needs, and we will help you make a smooth transition from the discontinued control. Our support team at https://support.boldreports.com/ is here to assist you with any questions or difficulties you may encounter during the migration process.

We thank you for choosing Syncfusion� and appreciate your understanding.

ReportViewer show no Report

Hi all together,
a very strange behavior with ReportViewer and MVVM

He runs perfectly if i'm running the same Report with different Data like printing Invoices.
As soon as i try to run a different Report there is NO visual rendering and no ErrorMessage.

<Border Name="groupBoxReportViewer" BorderThickness="3" 
                Grid.Column="1" Grid.Row="1" Grid.RowSpan="2" Margin="5" HorizontalAlignment="Stretch" VerticalAlignment="Stretch"  >
            <Grid>
                <sync:ReportViewer Name="viewer"   />
            </Grid>
        </Border>

Part of my ViewModel:

 void OnPrintViewer(ReportViewerModel reportViewerModel)
        {
    
            var logger = _container.Resolve<ILoggerFacade>();
            Console.WriteLine();
            logger.Log("BackstagePrintViewModel - OnPrintViewer called", Category.Info, Priority.Low);

            if (reportViewerModel.NamedDataSource != null)
            {
                logger.Log("BackstagePrintViewModel - Datasource != null", Category.Info, Priority.Low);
            }

            var viewer = GetReportViewer();
            try
            {
           
                logger.Log("get reportViewer", Category.Info, Priority.Low);

                viewer.ReportError += Viewer_ReportError;
                logger.Log("Setup Viewer", Category.Info, Priority.Low);
                SetupViewer(reportViewerModel, viewer);

                logger.Log("Set DataSource", Category.Info, Priority.Low);
                SetDataSource(reportViewerModel, viewer);
                logger.Log("Set Parameters", Category.Info, Priority.Low);
                SetParameters(reportViewerModel, viewer);
                logger.Log("Call Refresh", Category.Info, Priority.Low);
           
                logger.Log("Call RefreshReport", Category.Info, Priority.Low);
                viewer.RefreshReport();
                logger.Log("After RefreshReport", Category.Info, Priority.Low);
            }
            catch (Exception ee)
            {
                var errmess = String.Format("Error in ReportViewer {0}", ee.Message);
                logger.Log(errmess, Category.Exception, Priority.Low);
                throw ee;
            }
            finally
            {
                logger.Log("In Finally, reset <viewer.ReportError -= Viewer_ReportError> ", Category.Info, Priority.Low);
                viewer.ReportError -= Viewer_ReportError;
            }
          
        }


         ReportViewer GetReportViewer()
        { 
            var view = View as BackstagePrintView;
            return view.viewer;
        }

        
        void SetupViewer(ReportViewerModel reportViewerModel, ReportViewer reportViewer)
        {
            reportViewer.DataSources.Clear();
            reportViewer.ProcessingMode = ProcessingMode.Local;
            reportViewer.LoadReport(reportViewerModel.Report);
            
        }

Thanks in advance
Peter


3 Replies

MM Mageshyadav M Syncfusion Team August 14, 2018 09:30 AM UTC

Hi Peter, 
 
Based on your snippet, we cannot determine the exact cause for your reported issue. But we suspect, report path not set properly or viewer instance does not reset and refreshed properly. 
 
Hence we have created the sample with switching of reports containing different datasources using combobox to choose reports placed above viewer, 
 
 
ReportViewerModel Snippets: 
 
        public ReportModel Report { get; set; } 
 
        #region Constructor 
 
        public ReportViewModel() 
        { 
            this.Reports = new ObservableCollection<ReportModel>(); 
 
            ReportModel report1 = new ReportModel(); 
            report1.Name = "Report 1"; 
            report1.ReportPath = this.GetFullPath("Company Sales.rdlc"); 
            this.Reports.Add(report1); 
            ReportModel report2 = new ReportModel(); 
            report2.Name = "Report 2"; 
            report2.ReportPath = this.GetFullPath("drilldown.rdlc"); 
            this.Reports.Add(report2); 
        } 
 
        public void SelectionChanged(object param) 
        { 
            if (param != null) 
            { 
                foreach (object item in (IEnumerable)param) 
                { 
                    this.Report = item as ReportModel; 
                    this.SetupViewer(); 
                    this.SetDataSource(); 
                    this.viewer.RefreshReport(); 
                } 
            } 
        } 
 
        private void SetDataSource() 
        { 
            if (this.Report.Name == "Report 1") 
            { 
                this.viewer.DataSources.Add(new ReportDataSource("Sales", new CompanySalesDemo.AdventureWorks().GetDataTable())); 
            } 
            else 
            { 
                this.viewer.DataSources.Add(new ReportDataSource("Customers", CompanySalesDemo.Customers.GetData())); 
            } 
        } 
 
        public void Loaded(object sender, RoutedEventArgs e) 
        { 
            Window mainWindow = sender as Window; 
            this.viewer = mainWindow.FindName("viewer") as Syncfusion.Windows.Reports.Viewer.ReportViewer; 
            this.Report = new ReportModel() { Name = "Report 1", ReportPath = this.GetFullPath("Company Sales.rdlc") }; 
            this.SetupViewer(); 
            this.SetDataSource(); 
            this.viewer.RefreshReport(); 
        } 
 
        private void SetupViewer() 
        { 
            this.viewer.Reset(); 
            this.viewer.DataSources.Clear(); 
            this.viewer.ProcessingMode = ProcessingMode.Local; 
            this.viewer.ReportPath = this.Report.ReportPath; 
        } 
        private string GetFullPath(string report) 
        { 
            string templateDirectory = @"../../RDLC/"; 
            string dir = new DirectoryInfo(templateDirectory).FullName; 
            return System.IO.Path.Combine(dir, report);   
        } 
 
 
Please check this sample and try to load your created report. If the issue still persists, please share us the modified sample or report which is not loading properly which will be useful for us to determine the exact problem and provide accurate solution. 
 
Regards, 
Mageshyadav.M 



PR Padmini Ramamurthy Syncfusion Team August 20, 2018 05:09 AM UTC

From: peter.forstmeier
Sent: Saturday, August 18, 2018 12:56 AM
To: Syncfusion Support <[email protected]>
Subject: AW: Syncfusion support community forum 139236, ReportViewer show no Report, has been updated. 

Hi 
and a big thank you 
 
   private void SetupViewer()  
        {  
            this.viewer.Reset();  Thsi line does the trick 
 
Peter 
 



MM Mageshyadav M Syncfusion Team August 20, 2018 11:55 AM UTC

Hi Peter, 
  
Thanks for your update. We are glad to know that issue has been resolved on your side on calling reset method. 
  
Regards, 
Mageshyadav.M 


Loader.
Up arrow icon