Silverlight Report Viewer refresh

7 posts, 0 answers
  1. Chris Thierry
    Chris Thierry avatar
    138 posts
    Member since:
    Jun 2010

    Posted 28 Oct 2010 Link to this post

    Hello,

    I'm using silverlight report viewer, I need to refresh the report by programming.  I'm using RenderBegin and setting  the report parameters there.
    Any Suggestions on how to call the "Refresh" button on the report viewer by programming?

    Thanks
  2. Steve
    Admin
    Steve avatar
    10941 posts

    Posted 29 Oct 2010 Link to this post

    Hi Chris,

    The RefreshReportCommand Property is what you're looking for.

    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
  3. DevCraft banner
  4. Valentin Raceanu
    Valentin Raceanu avatar
    10 posts
    Member since:
    Jun 2012

    Posted 28 Jun 2011 Link to this post

    How can I access this property?
  5. Steve
    Admin
    Steve avatar
    10941 posts

    Posted 28 Jun 2011 Link to this post

    Hello Valentin,

    Here is a sample snippet that illustrates the 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.

    Kind 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
  6. Valentin Raceanu
    Valentin Raceanu avatar
    10 posts
    Member since:
    Jun 2012

    Posted 29 Jun 2011 Link to this post

    It works. But if "reportViewer" is not loaded yet (let's say it is in a tabcontrol) then GetChild(reportViewer, 0) throws an exception.
  7. James
    James avatar
    3 posts
    Member since:
    Jul 2011

    Posted 19 Aug 2011 Link to this post

    Hi all,

    I am currently trying to integrate the Telerik reporting control into a LightSwitch screen along with other controls. I was hoping to refresh the report when other selections on the screen changed using the method you described above. However, the command that selects the LayoutRoot child object from the ReportViewer is throwing an out of bounds exception. 

    Is there something I'm missing here, and has anyone else had a similar experience/problem?

    Thanks,
    James
  8. Steve
    Admin
    Steve avatar
    10941 posts

    Posted 22 Aug 2011 Link to this post

    Hi James,

    A possible reason for this error would be if the report viewer template has not yet been created e.g. you're invoking the extension method in the window/user control constructor. To make sure the template is available use OnApplyTemplate or any other event where you're sure the template is available.

    Best wishes,
    Steve
    the Telerik team

    Thank you for being the most amazing .NET community! Your unfailing support is what helps us charge forward! We'd appreciate your vote for Telerik in this year's DevProConnections Awards. We are competing in mind-blowing 20 categories and every vote counts! VOTE for Telerik NOW >>

Back to Top
DevCraft banner