Skip Navigation LinksHome / Community & Support / Developer Productivity Tools Forums / Reporting > Telerik Reporting > Problem getting the ReportViewerModel after upgrade to Q1'11

Not answered Problem getting the ReportViewerModel after upgrade to Q1'11

Feed from this thread
  • Paolo Master avatar

    Posted on Mar 16, 2011 (permalink)

    Hello,
    before I was getting the ReportViewerModel doing so :

    var reportViewerModel = reportViewer.DataContext as ReportViewerModel;

    Today after Q1'11 upgrade I get an Enum I define in the Main page hosting it.... why this happen?
    Thanks

    Reply

  • Chavdar Chavdar admin's avatar

    Posted on Mar 16, 2011 (permalink)

    Hello Paolo,

    This change is done on purpose in order to allow binding of report viewer properties directly to an inherited DataContext (see the release notes). If you have to get the ReportViewerModel then you should use the report viewer's first child instead. Here is a sample code snippet which shows how to achieve this:

    var layoutRoot = (FrameworkElement)VisualTreeHelper.GetChild(this.ReportViewer1, 0);
    var rvm = (ReportViewerModel)(layoutRoot.DataContext);

    This works both for WPF and Silverlight report viewers.

    However the ReportViewerModel in both Silverlight and WPF report viewers is intended for internal use by the controls and we will appreciate if you share with us your particular case that demands the use of the ReportViewerModel.

    All the best,
    Chavdar
    the Telerik team
    Registration for Q1 2011 What’s New Webinar Week is now open. Mark your calendar for the week starting March 21st and book your seat for a walk through all the exciting stuff we ship with the new release!

    Reply

  • PCF avatar

    Posted on May 11, 2011 (permalink)

    Hello,
    If it's similar to the use case I'm in right now, we need a way to refresh the report using parameters that can only be set from outside of the ReportViewer...and we're using Silverlight MVVM.

    The previous version allowed you to do this, and it worked quite well:
    ((ReportViewerModel)this.InvoiceReportViewer.DataContext).RefreshReportCommand.Execute(null);

    Now, as you mentioned, that breaks.
    The issue with the work-around now is that my report does not have a child and the call to GetChild(ReportViewer, 0) now breaks with this error:
    Specified argument was out of the range of valid values.
    Parameter name: childIndex

    I don't want to un-upgrade all the reports but that's what I'll have to do I guess...

    Reply

  • Steve Steve avatar

    Posted on May 16, 2011 (permalink)

    Hi PCF,

    Here is a working sample snippet tested on our demos that illustrates this approach:
    Copy Code
    Copy Code
    public partial class MainPage : UserControl
    {
        public MainPage()
        {
            InitializeComponent();
        }
     
        void button1_Click(object sender, RoutedEventArgs e)
        {
            this.ReportViewer1.RefreshReport();
        }
    }
     
    static class ReportViewerExtensions
    {
        public static void RefreshReport(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 it helps.

    Regards,
    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

    Reply

  • Andrew Smith avatar

    Posted on May 16, 2011 (permalink)

    I was using this to hide the parameters area.

     If e.PropertyName = "IsParametersAreaVisible" _
        AndAlso CType(reportv.DataContext, ReportViewerModel).IsParametersAreaVisible _
        AndAlso m_bOverwriteReportParameters Then


          CType(reportv.DataContext, ReportViewerModel).IsParametersAreaVisible = False
          m_bOverwriteReportParameters = False
        End If

    Reply

  • Posted on May 31, 2011 (permalink)

    Hi,

    I am trying to make sense of how MVVM fits into the Silverlight ReportViewer but I am just too unfamiliar with Telerik Reports to make any sense of it.

    I've logged a support ticket under my account regarding, but this article seems that you are saying that the DataContext will inherit in Silverlight.

    Am I suppose to create the Report with an Objectdatasource or without, any nice walkthroughs on this just simply explaining ReportViewer, Silverlight and MVVM. I can imagine if you know what goes where it is really simple but I am unable to get any data shown in my report from my ViewModel.

    I have a report with no datasource, and set the DataContext of the Report Viewer to my Model which is an ObservableCollection of a class with Properties. I then also created a Binding on the TextBlock in the Report to a string of the Property. Pretty much what you would do in a normal RadGridView.

    Thanks,
    Anton

    Reply

  • Peter Peter admin's avatar

    Posted on May 31, 2011 (permalink)

    Hello Anton,

    For now Telerik Reports reside on the server and the Silverlight ReportViewer always requires the Telerik Reporting WCF Service, which acts as a communication interface between the client (Silverlight) and the report server. Currently the reporting engine is not compatible with Silverlight and it requires .NET framework to perform its operations. Thus the report can't utilize the Silverlight's DataContext but instead rely on the datasource components that are defined in the report definition.

    You may find useful the following help resources:


    Anyway we already have a couple of ideas how to improve the integration of the Reporting engine with Silverlight, but due to some limitations of the framework we will stay with the report service for now.

    All the best,
    Peter
    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

    Reply

  • facundo avatar

    Posted on Feb 2, 2012 (permalink)

    Hello Peter,

    I'm working with the Reporting WCF Services and ReportViewerModel. I want to change an exception error that I get from a WCF service call. The thing is that I have my reports in another server and I'm doing some testing regarding reports service connection, so my test consists in trying to render a report simulating a lost of service connection. Once that happens, I got a big timeout exception inside the Report Designer that I'd like to change to an user-friendly message.

    I've been using the ReportViewerModel.Error property to set my custom message in the service callback, but sometimes the Error property gets override for the original exception message.

    How could I display custom messages inside the report designer?
    How can I handle those types of custom error message?

    Thanks in advance.

    UJazz.

    Reply

Back to Top

Skip Navigation LinksHome / Community & Support / Developer Productivity Tools Forums / Reporting > Telerik Reporting > Problem getting the ReportViewerModel after upgrade to Q1'11
Related resources for "Problem getting the ReportViewerModel after upgrade to Q1'11"

Features  |  Documentation  |  Demos  |  Telerik TV  |  Knowledge Base  |  Code Library  |  Step-by-step Tutorial  |  Blogs  |  Whitepaper  ]