I have a DataGrid in a user control of my WPF app, and I want when the user selects some rows from here, send DataGrid.SelectedItems as DataSource to my Telerik Report, and I don't know how i can do this, somebody have an example to help me?
14 Answers, 1 is accepted
You can use a custom function to save the values selected from the DataGrid and use this function to set the report's DataSource property via bindings.
Check User functions help article and let us know if you need any additional information.
Regards,
Katia
Telerik by Progress
Thank you so much Katia, but, my telerik report only print a bar code for a idprod and her description, is a label product print, and I want to send to the report an array or list or any IEnumerable with all idprod and her description previouslly selected by the user, and in the telerik report no use any DataSource, because I don't want to Access the data base again to get the same data if I can send it as parameter...I don't know if I can explain myself...
I want to send:
23458 Air filter
25478 Diesel filter
26878 Transmission oil
and I need to print for each a label with code bar for the idprod, and description....
I attach a images related.
Right now Works, but the report is called for each product selected, and show me the printer window for every one
Instead of iterating over the collection of grdProductos.SelectedItems and adding a new parameter for each of the items, you can set the report.DataSource property directly to grdProductos.SelectedItems.
To access the DataSource property of the report, create a new instance of rpEtiqueta report. After the data is passed to report.DataSource, set the modified report as ReportDocument of InstanceReportSource.
As the data source is not available during design-time, the data fields must be typed in manually (= Fields.pIDProd) or you can use the approach described in Working With Data at Design Time(Data source available only at runtime) help article.
Regards,
Katia
Telerik by Progress
"To access the DataSource property of the report, create a new instance of rpEtiqueta report. After the data is passed to report.DataSource, set the modified report as ReportDocument of InstanceReportSource."
:(
I got it, I think, I made:
Report rpt = new rpEtiquetaProductos();
rpt.DataSource = grdProductos.SelectedItems;
ReportViewer1.ReportSource = rpt; // <-BUT HERE SAY ME IS OBSOLETE ?
ReportViewer1.PrintReport();
But now Works as I need
Setting the viewer's ReportSource directly to a report instance is obsolete as of Q2 2012 - How to migrate your project to utilize the new ReportSource objects.
The new approach is to use a ReportSource object to set the viewer's ReportSource, for example:
Report rpt =
new
rpEtiquetaProductos();
rpt.DataSource = grdProductos.SelectedItems;
Telerik.Reporting.InstanceReportSource instanceReportSource =
new
Telerik.Reporting.InstanceReportSource();
instanceReportSource.ReportDocument = rpt;
ReportViewer1.ReportSource = instanceReportSource;
Regards,
Katia
Telerik by Progress
ooohhhhh, ok, perfect, I made the change right now, thank you so much Katia
Regards
No Katia, I made the change but,in the tests, when I select 6 products, it only show me 4, then in another test show me 0, I think some thing is wrong but I don't know what, please help me!!
When I'm in the telerik report designer, I defined a SQL Data Source in wich I read the Products table, and in my user control of WPF asigned to the report the DataSource with the products selected by the user, but don't work
No Katia, I made the change but,in the tests, when I select 6 products, it only show me 4, then in another test show me 0, I think some thing is wrong but I don't know what, please help me!!
When I'm in the telerik report designer, I defined a SQL Data Source in wich I read the Products table, and in my user control of WPF asigned to the report the DataSource with the products selected by the user, but don't work
Test switching to Print preview in the Designer or in the WPF Report Viewer - Interactive vs. Print Layout.
Also, check if the report has any filters applied and test modifying the filter expression.
To provide you more accurate suggestions we would need to check a sample project reproducing the issue and demonstrating your current setup.
Regards,
Katia
Telerik by Progress
No problem at all. I am glad that you discovered the cause of the issue.
Let us know if any other questions come up.
Regards,
Katia
Telerik by Progress