Good Evenign
i am not using MVVM parttern, i looked for examples here on our site and could not find just a simple way to refresh a Reportviewer in Silverlight. The Scenirio is simple. i have a listbox outside the Report, and when the SelectedChanged even is fire, i want to refresh the report, So i tried to call the Asnyc of the "reportViewer1_RenderBegin" Event , but nothing is happenig. my renderbegin is initializing the report parameters. So i want to refresh a report.
THanks
i am not using MVVM parttern, i looked for examples here on our site and could not find just a simple way to refresh a Reportviewer in Silverlight. The Scenirio is simple. i have a listbox outside the Report, and when the SelectedChanged even is fire, i want to refresh the report, So i tried to call the Asnyc of the "reportViewer1_RenderBegin" Event , but nothing is happenig. my renderbegin is initializing the report parameters. So i want to refresh a report.
THanks
11 Answers, 1 is accepted
0
Accepted
Hi Vuyiswa Maseko,
As of Q1 2011 release of Telerik Reporting the ReportViewerModel cannot be taken from the DataContext of the viewer. This is done on purpose in order to allow binding to an inherited DataContext from the viewer's properties. The new way to get the model is from the viewer's first child. Here is a sample snippet that illustrates this approach:
Hope it helps.
Regards,
Steve
the Telerik team
As of Q1 2011 release of Telerik Reporting the ReportViewerModel cannot be taken from the DataContext of the viewer. This is done on purpose in order to allow binding to an inherited DataContext from the viewer's properties. The new way to get the model is from the viewer's first child. Here is a sample snippet that illustrates this approach:
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
0
Vuyiswa
Top achievements
Rank 2
answered on 30 Mar 2011, 06:34 PM
You are a star this works perfectly.
Thank again for your time, i will have to bother you with a non reporting quetion. i have posted it here
http://www.telerik.com/community/forums/silverlight/gridview/single-select-on-a-gridview.aspx
Thanks for your help.
Thank again for your time, i will have to bother you with a non reporting quetion. i have posted it here
http://www.telerik.com/community/forums/silverlight/gridview/single-select-on-a-gridview.aspx
Thanks for your help.
0
VH
Top achievements
Rank 1
answered on 31 Mar 2011, 05:17 AM
Hi,
I want the report to be able to refresh automatically every time it is shown.
Before I upgraded to Q1 2011, I used ((ReportViewerModel)report.DataContext).RefreshReportCommand.Execute(null); to refresh it.
But with Q1 2011, I have tried what you suggested, but my reportviewer doesn't have any children, so when I try to call
var layoutRoot = (FrameworkElement)VisualTreeHelper.GetChild(reportViewer, 0); it gets error.
In this case what should I do?
Thank you for your help.
I want the report to be able to refresh automatically every time it is shown.
Before I upgraded to Q1 2011, I used ((ReportViewerModel)report.DataContext).RefreshReportCommand.Execute(null); to refresh it.
But with Q1 2011, I have tried what you suggested, but my reportviewer doesn't have any children, so when I try to call
var layoutRoot = (FrameworkElement)VisualTreeHelper.GetChild(reportViewer, 0); it gets error.
In this case what should I do?
Thank you for your help.
0
Pediatric Computing
Top achievements
Rank 1
answered on 11 May 2011, 03:55 PM
Hello there,
I'm having the same exact problem. It was working great using the old Q3 2010 routine, and then I went and upgraded the reports using the upgrade wizard and now I'm having the same problem because my ReportViewer doesn't have a child and it blows up trying to GetChild().
Help!
I'm having the same exact problem. It was working great using the old Q3 2010 routine, and then I went and upgraded the reports using the upgrade wizard and now I'm having the same problem because my ReportViewer doesn't have a child and it blows up trying to GetChild().
Help!
0
Accepted
Hello PCF,
The only reason for this problem 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 e.g.:
Regards,
Steve
the Telerik team
The only reason for this problem 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 e.g.:
public
partial
class
MainPage : UserControl
{
public
MainPage()
{
InitializeComponent();
}
public
override
void
OnApplyTemplate()
{
base
.OnApplyTemplate();
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
);
}
}
}
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
Vuyiswa
Top achievements
Rank 2
answered on 17 May 2011, 07:20 AM
Good Day ,
Thank you for your reply.
This has worked for me. I have another question that i have asked in the other forum , maybe you can kindly answer me
http://www.telerik.com/community/forums/silverlight/htmlplaceholder/payment-gateway-in-silverlight.aspx
Thanks
Thank you for your reply.
private
void
reportViewer1_RenderBegin(
object
sender, Telerik.ReportViewer.Silverlight.RenderBeginEventArgs args)
{
KidsModelExtended selectedkid = lstkids.SelectedItem
as
KidsModelExtended;
if
(selectedkid !=
null
)
{
int
Kidid = selectedkid.iKidid;
args.ParameterValues[
"KIDID"
] = Kidid;
}
}
http://www.telerik.com/community/forums/silverlight/htmlplaceholder/payment-gateway-in-silverlight.aspx
Thanks
0
Hi PCF,
Your other thread has been already answered. We hope you will find the provided links useful.
Greetings,
Chavdar
the Telerik team
Your other thread has been already answered. We hope you will find the provided links useful.
Greetings,
Chavdar
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
Wayne
Top achievements
Rank 1
answered on 12 Apr 2012, 10:59 AM
Hi Steve,
I have the same problem as in the last couple of posts. I have added the public override void OnApplyTemplate() function but this does not now execute. The Report I have in a Tab control, when I click on the tab I set the SelectedTabIndex. The report then renders once. I need it to render each time I change tabs. In one tab I set the parameters in the other I display the report viewer.
Thanks and kind regards
Wayne
0
Hello Wayne,
Do you have the problem if the viewer is outside of the RadTab? The RadTabControl adds report viewer every time the tab content is displayed and removes it from the visual tree every time the tab content is hidden(another tab content is displayed). So the current behavior of the report viewer is appropriate and by design.
If you need to keep each RadTabItem's content you can set the IsContentPreserved property of RadTabControl to True.
All the best,
Steve
the Telerik team
Do you have the problem if the viewer is outside of the RadTab? The RadTabControl adds report viewer every time the tab content is displayed and removes it from the visual tree every time the tab content is hidden(another tab content is displayed). So the current behavior of the report viewer is appropriate and by design.
If you need to keep each RadTabItem's content you can set the IsContentPreserved property of RadTabControl to True.
All the best,
Steve
the Telerik team
NEW in Q1'12: Telerik Report Designer (Beta) for ad-hoc report creation. Download as part of Telerik Reporting Q1 2012. For questions and feedback, use the new Telerik Report Designer Forum.
0
Wayne
Top achievements
Rank 1
answered on 18 Apr 2012, 10:53 AM
Thanks, its working fine now.
kind regards
Wayen
kind regards
Wayen
0
Vitrum
Top achievements
Rank 1
answered on 08 Nov 2013, 11:32 AM
ReportViewer1.Report=""
ReportViewer1.Report="ReportName, ReportLibrary"
ReportViewer1.Report="ReportName, ReportLibrary"