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

Silverlight sender parameter to Report

3 Answers 81 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
Yunfan
Top achievements
Rank 1
Yunfan asked on 21 Dec 2011, 10:13 AM
 Hello,
I have a problem about the Telerik Report. I found a report with parameters when I scanning the examples about Silverlight how to call the WCF report. You made it work for adding a combox in the component element of WCF report. If the combox is in the Silverlight, Would you tell me how to realize it which the report with the parameter .How can I pass this parameter to the control of WCF report and make it display dynamic?

3 Answers, 1 is accepted

Sort by
0
Elian
Telerik team
answered on 21 Dec 2011, 05:50 PM
Hello Yunfan,

The following KB article elaborates on passing values to report parameters from the Silverlight client: Programmatic Initialization of Report Parameter Values in Telerik Reporting Silverlight Viewer.

Regards,
Elian
the Telerik team

Q3’11 of Telerik Reporting is available for download. Register for the What's New in Data Tools webinar to see what's new and get a chance to WIN A FREE LICENSE!

0
Yunfan
Top achievements
Rank 1
answered on 22 Dec 2011, 02:54 AM
I understand , but you say is in the page load.
 Now, I will dynamically Change the report Content in the ComboBox SelectionChanged event  ,in the same time refresh the report by the CSharp code, Please help me (⊙_⊙)?
0
Accepted
Elian
Telerik team
answered on 23 Dec 2011, 02:01 PM
Hi,
  1. Add this extensions method that will allow you to refresh your report whenever you want:
    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);
               }
           }
  2. Follow the before mentioned article about passing the parameters. For example:
    void ReportViewer1_RenderBegin(object sender, RenderBeginEventArgs args)
    {
       args.ParameterValues["ProductCategory"] = myComboBox.SelectedValue;
    }
    This is an event handler that will be called every time the report starts to render (every time you refresh it).

  3. Then when you selected the desired parameters in the Silverlight app call the RefreshReportMethod()
    void ComboBox_OnSelectionChanged(object sender, RenderBeginEventArgs args)
    {
       //This will force the report to refresh and
       //the report will get the new parameter values
       ReportViewer1.RefreshReport();
    }

Regards,
Elian
the Telerik team

Q3’11 of Telerik Reporting is available for download. Register for the What's New in Data Tools webinar to see what's new and get a chance to WIN A FREE LICENSE!

Tags
General Discussions
Asked by
Yunfan
Top achievements
Rank 1
Answers by
Elian
Telerik team
Yunfan
Top achievements
Rank 1
Share this question
or