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

How to set the report source for a viewer in a User Control from another control

1 Answer 160 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
Spencer
Top achievements
Rank 1
Spencer asked on 21 Jan 2014, 07:40 PM
Hello,

I have a User control built like the example in the Reporting documentation("How to: Add report viewer to a WPF application"), where the report viewer control is added to the user control, and the report source is set in the control constructor. I then open the report by adding the control to a RadPane and adding it to the Main WPF Window. My question: how can I set the report source from outside the control before or after I add it to the RadPane? Here's how I open the report:

Grid

 

 

grid = new Grid();

 

grid = PanelGrid();

 

 


TextBlock title = new TextBlock();

 

title = DisplayText();

title.Text =

 

"PSR Report";

 

 

 


 

 

 

Frame addFrame = new Frame();

 

 

 

//Report Viewer is the control with the embedded viewer

 

// How can I specify the report source from here??
//
addFrame.Source =

 

new System.Uri("/ReportViewers/ReportViewer.xaml", UriKind.Relative);

 

 

 


//Create RadPane

 

 

 

RadPane PSRPanel = new RadPane();

 

PSRPanel.Header =

 

"Report Viewer";

 

PSRPanel.Content = grid;

 

 


MainWindow.mw1.radPaneGroup.Items.Add(PSRPanel);

 

 

 


Grid.SetRow(title, 0);

 

grid.Children.Add(title);

 

 

Grid.SetRow(addFrame, 1);

 

grid.Children.Add(addFrame);

Thanks,
Spencer

1 Answer, 1 is accepted

Sort by
0
IvanY
Telerik team
answered on 24 Jan 2014, 04:09 PM
Hi Spencer,

You can add a method to your user control, for example SetDataSource(ReportSource reportSource). Then on opening and closing the RadPane invoke this method. In the method you can either create new report viewer, configure it and set a new data source or you can have a single instance of the report viewer in the control and set its data source.

Regards,
IvanY
Telerik

New HTML5/JS REPORT VIEWER with MOBILE AND TOUCH SUPPORT available in Telerik Reporting Q3 2013! Get the new Reporting version from your account or download a trial.

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