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

Silverlight Report Viewer refresh

6 Answers 211 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
Chris Thierry
Top achievements
Rank 1
Chris Thierry asked on 28 Oct 2010, 04:20 PM
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

6 Answers, 1 is accepted

Sort by
0
Steve
Telerik team
answered on 29 Oct 2010, 09:32 AM
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
0
Valentin Raceanu
Top achievements
Rank 1
answered on 28 Jun 2011, 02:46 PM
How can I access this property?
0
Steve
Telerik team
answered on 28 Jun 2011, 05:44 PM
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
0
Valentin Raceanu
Top achievements
Rank 1
answered on 29 Jun 2011, 08:16 AM
It works. But if "reportViewer" is not loaded yet (let's say it is in a tabcontrol) then GetChild(reportViewer, 0) throws an exception.
0
James
Top achievements
Rank 1
answered on 19 Aug 2011, 08:52 PM
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
0
Steve
Telerik team
answered on 22 Aug 2011, 04:50 PM
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 >>

Tags
General Discussions
Asked by
Chris Thierry
Top achievements
Rank 1
Answers by
Steve
Telerik team
Valentin Raceanu
Top achievements
Rank 1
James
Top achievements
Rank 1
Share this question
or