Equipe Info
Top achievements
Rank 1
Equipe Info
asked on 03 Sep 2010, 09:44 AM
Hello,
For a new project we are trying tu use the Telerik's ReportViewer control in SILVERLIGHT.
We are using RIA Services/Prism/MVVM/SILVERLIGHT for our project.
ReportViewer is working fine but we needs some parameters in the report to be initialized by user input in the view.
So we need the RenderBegin method to be in the ViewModel and then we need to use a trigger in our view :
View :
ListViewModel comes from a ViewModelHelper, and Interactivity from System.Windows.Interactivity
The ViewModel:
With all this code, the RenderBegin Method is not called... So, does the interactivity trigger and the renderbegin method can work together ?
We can't use reportviewer without parameters in our report...
Thanks for your help.
FYI: Triggers are working fine in all of our project, for button events or combobox event or dataform events...
For a new project we are trying tu use the Telerik's ReportViewer control in SILVERLIGHT.
We are using RIA Services/Prism/MVVM/SILVERLIGHT for our project.
ReportViewer is working fine but we needs some parameters in the report to be initialized by user input in the view.
So we need the RenderBegin method to be in the ViewModel and then we need to use a trigger in our view :
View :
<
telerik:ReportViewer
Height
=
"400"
Margin
=
"0,10,0,0"
Visibility
=
"{Binding ViewModel.ReportVisibility, Source={StaticResource ListViewModel}}"
ReportServiceUri
=
"../ReportService.svc"
Report
=
"Jet2.Server.ReportLibrary.ReportTest, Jet2.Server.ReportLibrary, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null"
ZoomMode
=
"PageWidth"
>
<
interactivity:Interaction.Triggers
>
<
interactivity:EventTrigger
EventName
=
"RenderBegin"
>
<
infrastructureCommands:InvokeDelegateCommandAction
Command
=
"{Binding ViewModel.RenderBeginCommand, Source={StaticResource ListViewModel}}"
CommandParameter
=
"{Binding RelativeSource={RelativeSource Self}, Path=InvokeParameter}"
/>
</
interactivity:EventTrigger
>
</
interactivity:Interaction.Triggers
>
</
telerik:ReportViewer
>
The ViewModel:
//The Command
public
DelegateCommand<RenderBeginEventArgs> RenderBeginCommand {
get
;
private
set
; }
//In the ViewModel Constructor:
this
.RenderBeginCommand =
new
DelegateCommand<RenderBeginEventArgs>(
this
.BeginRenderReport);
//The RenderBegin Method:
private
void
BeginRenderReport(RenderBeginEventArgs rbea)
{
rbea.ParameterValues[
"CompanyId"
] =
this
.CurrentCompany.Id;
}
With all this code, the RenderBegin Method is not called... So, does the interactivity trigger and the renderbegin method can work together ?
We can't use reportviewer without parameters in our report...
Thanks for your help.
FYI: Triggers are working fine in all of our project, for button events or combobox event or dataform events...
9 Answers, 1 is accepted
0
Accepted
Hi Equipe Info,
Bellow you can find a sample implementation which shows one of the possible ways to refresh a report from an external for the viewer view-model. Please, take a look at it and let us know whether this approach is suitable in your case.
Hope this helps.
Best wishes,
Chavdar
the Telerik team
Bellow you can find a sample implementation which shows one of the possible ways to refresh a report from an external for the viewer view-model. Please, take a look at it and let us know whether this approach is suitable in your case.
<
UserControl.Resources
>
<
local:ViewModel
x:Key
=
"ViewModel1"
/>
</
UserControl.Resources
>
public
partial
class
MainPage : UserControl
{
ViewModel vm;
public
MainPage()
{
InitializeComponent();
vm = (ViewModel)
this
.Resources[
"ViewModel1"
];
vm.RefreshReport +=
new
System.Action(vm_RefreshReport);
this
.ReportViewer1.RenderBegin += vm.ReportViewerRenderBegin;
}
void
vm_RefreshReport()
{
((ReportViewerModel)
this
.ReportViewer1.DataContext).RefreshReportCommand.Execute(
null
);
}
private
void
Button_Click(
object
sender, RoutedEventArgs e)
{
vm.UpdateReport();
}
}
public
class
ViewModel : INotifyPropertyChanged
{
public
event
PropertyChangedEventHandler PropertyChanged;
public
event
System.Action RefreshReport;
Visibility visibility;
public
ViewModel()
{
}
public
Visibility ReportVisibility
{
get
{
return
this
.visibility;
}
set
{
this
.visibility = value;
this
.NotifyChanged(
"Visibility"
);
}
}
void
NotifyChanged(
string
propertyName)
{
if
(
null
!=
this
.PropertyChanged)
{
this
.PropertyChanged(
this
,
new
PropertyChangedEventArgs(propertyName));
}
}
public
void
ReportViewerRenderBegin(
object
sender, RenderBeginEventArgs args)
{
// Your custom code to set the report parameters from your model.
}
public
void
UpdateReport() // Call this method whenever the report should be refreshed.
{
if
(
this
.RefreshReport !=
null
)
{
this
.RefreshReport();
}
}
}
Hope this helps.
Best wishes,
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
Equipe Info
Top achievements
Rank 1
answered on 07 Sep 2010, 11:34 AM
Hi,
Thanks for your answer but this implementation is not MVVM... We were able to make it works but we had to break our MVVM.
So this approach is not suitable at all because our entire project is MVVM.
A such expensive componant for Silverlight should work with MVVM.
We are not sure yet if we are going to buy your Reporting componant but we hope that Telerik will work on MVVM compatibility in the next releases.
Thanks again for your help !
Thanks for your answer but this implementation is not MVVM... We were able to make it works but we had to break our MVVM.
So this approach is not suitable at all because our entire project is MVVM.
A such expensive componant for Silverlight should work with MVVM.
We are not sure yet if we are going to buy your Reporting componant but we hope that Telerik will work on MVVM compatibility in the next releases.
Thanks again for your help !
0
Mariusz
Top achievements
Rank 1
answered on 01 Jun 2011, 11:57 AM
Hello,
I've encountered similar problem to the one described in the first post. I managed to pass event args to a command in my viewmodel, but the following problem occur. Sometimes arguments arrive too early and my report is not displayed correctly. I need to push refresh button to fix it. My question is how to refresh report after parameters are set.
view's code behind:
view:
RenderReport command is a command property in my viewmodel. It simply passes values to event arguments object. It works each time, but report is displayed correctly 9/10 of the time. I don't know where to put execution of refresh command.
I put this post here because i think the code might be helpful for someone.
Any help is apriciated. Thanks in advance.
I've encountered similar problem to the one described in the first post. I managed to pass event args to a command in my viewmodel, but the following problem occur. Sometimes arguments arrive too early and my report is not displayed correctly. I need to push refresh button to fix it. My question is how to refresh report after parameters are set.
view's code behind:
public
partial
class
ReportView : RadWindow
{
public
ReportView()
{
InitializeComponent();
ReportViewer.RenderBegin +=
new
RenderBeginEventHandler(RenderBeginHandler);
}
public
RenderBeginEventArgs EventArgs
{
get
{
return
(RenderBeginEventArgs)GetValue(EventArgsProperty); }
set
{ SetValue(EventArgsProperty, value); }
}
public
static
readonly
DependencyProperty EventArgsProperty =
DependencyProperty.Register(
"EventArgs"
,
typeof
(RenderBeginEventArgs),
typeof
(ReportView),
new
PropertyMetadata(
null
));
private
void
RenderBeginHandler(
object
sender, RenderBeginEventArgs rbea)
{
EventArgs = rbea;
}
}
view:
<
t:RadWindow
xmlns:t
=
"http://schemas.telerik.com/2008/xaml/presentation"
xmlns:v
=
"clr-namespace:Telerik.ReportViewer.Silverlight;assembly=Telerik.ReportViewer.Silverlight"
xmlns:interactivity
=
"clr-namespace:System.Windows.Interactivity;assembly=System.Windows.Interactivity"
xmlns:ei
=
"clr-namespace:Microsoft.Expression.Interactivity.Core;assembly=Microsoft.Expression.Interactions"
x:Name
=
"ReportWindow"
>
<
interactivity:Interaction.Triggers
>
<
ei:PropertyChangedTrigger
Binding
=
"{Binding EventArgs, ElementName=ReportWindow}"
>
<
interactivity:InvokeCommandAction
Command
=
"{Binding ViewModel.RenderReport, Source={StaticResource Locator}}"
CommandParameter
=
"{Binding EventArgs, ElementName=ReportWindow}"
/>
</
ei:PropertyChangedTrigger
>
</
interactivity:Interaction.Triggers
>
<
Grid
x:Name
=
"LayoutRoot"
Background
=
"White"
>
<
v:ReportViewer
x:Name
=
"ReportViewer"
/>
</
Grid
>
</
t:RadWindow
>
RenderReport command is a command property in my viewmodel. It simply passes values to event arguments object. It works each time, but report is displayed correctly 9/10 of the time. I don't know where to put execution of refresh command.
I put this post here because i think the code might be helpful for someone.
Any help is apriciated. Thanks in advance.
0
Massimiliano Bassili
Top achievements
Rank 1
answered on 02 Jun 2011, 03:40 PM
Intermittent problems are the hardest to reproduce especially if the rate is 9 out of 10. Providing a sample project that shows the problem would help identify what the issue is (if reproducible on other machine at all).
Honestly it looks to me that there is something else going on that is slowing down the viewer initialization, so you cannot set the param values.
You say that the report is not displayed correctly - can you elaborate on that part?
Cheers!
Honestly it looks to me that there is something else going on that is slowing down the viewer initialization, so you cannot set the param values.
You say that the report is not displayed correctly - can you elaborate on that part?
Cheers!
0
Rob Ainscough
Top achievements
Rank 1
answered on 09 May 2014, 10:34 PM
We're running into the same problem, I know this is a 4 year old post, so I'm hoping some progress was made so I can stay with MVVM? We're using Telerik Reporting Services for Q1 2013.
We can get everything working using Code Behind but when I try to move it to MVVM the using EventTrigger (from SL5 interactions) with EventName = RenderBegin or OnRenderBegin ... it never fires the event.
Could someone provide any hints on how to make this work the MVVM way?
Thanks, Rob.
We can get everything working using Code Behind but when I try to move it to MVVM the using EventTrigger (from SL5 interactions) with EventName = RenderBegin or OnRenderBegin ... it never fires the event.
Could someone provide any hints on how to make this work the MVVM way?
Thanks, Rob.
0
Hi Rob,
This is a quote from your support ticket on the same question:
"The EventTrigger can be triggered only by a RoutedEvent and the RenderBegin event of the viewer is not of this type. Therefore it is normal for this approach not to work. The routed events are a special category of events and currently we presume that our event should not fall into this category due to its specifics.
An easy solution for the problem could be to inherit the ReportViewer class and create a custom RoutedEvent for this purpose. You have to wire the RenderBegin event in the constructor of the inherited class and call your routed event from its event handler. Afterwards you can use the newly created control on different places with the EventTrigger and your routed event name."
If you have further questions, let us continue the discussion in your support ticket #818283.
Regards,
Stef
Telerik
This is a quote from your support ticket on the same question:
"The EventTrigger can be triggered only by a RoutedEvent and the RenderBegin event of the viewer is not of this type. Therefore it is normal for this approach not to work. The routed events are a special category of events and currently we presume that our event should not fall into this category due to its specifics.
An easy solution for the problem could be to inherit the ReportViewer class and create a custom RoutedEvent for this purpose. You have to wire the RenderBegin event in the constructor of the inherited class and call your routed event from its event handler. Afterwards you can use the newly created control on different places with the EventTrigger and your routed event name."
If you have further questions, let us continue the discussion in your support ticket #818283.
Regards,
Stef
Telerik
Check out the Telerik Platform - the only platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native mobile apps.
0
Rob Ainscough
Top achievements
Rank 1
answered on 15 May 2014, 07:01 PM
Hi Stef,
I've been working with Chavdar on the problem and sadly not luck using the Inherit ReportViewer process ... the event is still never triggered and I get no reports displayed. The only way I can make this work is using Code Behind ... MVVM approach is still a NO GO unfortunately.
Also (may or maynot be related) your documentation here (WCF Silverlight) suggests using this one line in the Reporting service:
When I use this line I get a warning: Cannot resolve symbol "ReportService" .
Rob
I've been working with Chavdar on the problem and sadly not luck using the Inherit ReportViewer process ... the event is still never triggered and I get no reports displayed. The only way I can make this work is using Code Behind ... MVVM approach is still a NO GO unfortunately.
Also (may or maynot be related) your documentation here (WCF Silverlight) suggests using this one line in the Reporting service:
<%@ ServiceHost Service="Telerik.Reporting.Service.ReportService, Telerik.Reporting.Service, Version=8.0.14.507, Culture=neutral, PublicKeyToken=a9d7983dfcc261be" %>
When I use this line I get a warning: Cannot resolve symbol "ReportService" .
Rob
0
Hi,
This is an update for anyone concerned. The attached project illustrates the solution suggested by my colleague Chavdar.
Regards,
Stef
Telerik
This is an update for anyone concerned. The attached project illustrates the solution suggested by my colleague Chavdar.
Regards,
Stef
Telerik
Check out the Telerik Platform - the only platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native mobile apps.
0
Rob Ainscough
Top achievements
Rank 1
answered on 19 May 2014, 05:54 PM
HI Stef,
Chavdar project does indeed work ... I wasn't able to get it to fire the method I set, but it did trigger the OnRenderBegin in my inherited class and I was able to set the parameters there so the report would display. Not perfect solution, but good enough for me.
Rob Ainscough
Chavdar project does indeed work ... I wasn't able to get it to fire the method I set, but it did trigger the OnRenderBegin in my inherited class and I was able to set the parameters there so the report would display. Not perfect solution, but good enough for me.
Rob Ainscough