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

RadGridView to Report

3 Answers 181 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
Ricky
Top achievements
Rank 1
Ricky asked on 24 Feb 2012, 08:21 PM
Hello,

I want to allow the user to use the Telerik's RadGridView control to query a list of objects using the control's filters. I then want to send the user filtered list to a Telerik report. What would be the best way to achieve this?

Thank you,

Ricky

3 Answers, 1 is accepted

Sort by
0
Accepted
Hadib Ahmabi
Top achievements
Rank 1
answered on 27 Feb 2012, 12:25 PM
It depends on the technology you use. If you use silverlight you will have to a lot of work (close to magic).
For the rest:
a) If you can, get the filtered data (Like IEnumerable or something similar) then simply pass it to the Report.DataSource
b) If you can't, get the filter descriptors from the grid and pass them to the report (you can extend the report class with some properties or something like that, that will allow you to pass the objects). Then you will need to read them and make custom logic as to how to filter the report's data source. 
0
Ricky
Top achievements
Rank 1
answered on 27 Feb 2012, 11:15 PM
Hadib, 

Thank you very much for your post! It helped me a lot in not wasting any time.

I am indeed using Silverlight & and have managed to make magic happen!

I used a Database View that I queried in a service to populate the radgrid. I then passed the radgrid's filter logic as string parameters in an object array to the report from the silverlight report viewer code behind. (source: http://www.telerik.com/support/kb/reporting/report-viewers/programmatic-initialization-of-report-parameter-values-in-telerik-reporting-silverlight-viewer.aspx )

I did run into a hiccup in that the parameters seemed to be NULL whenever I accessed it from the report's constructor; however, I added a  Report_ItemDataBinding event and the parameters were populated when that event fired. After this, it was a simple matter of programmacically setting filters to the report (which was the same database view that was used to populated the radgridview).

ie: 

this.Report.Filters.Add(new Telerik.Reporting.Data.Filter { Expression = "Fields.Date", Operator = Telerik.Reporting.Data.FilterOperator.GreaterOrEqual, Value = startDate.Date.ToString() });

I'm not sure if this is the best way to do it, but it was the easiest way I could figure out.

Thanks again!

Also, I'm digging the Mario & Luigi!
0
Hadib Ahmabi
Top achievements
Rank 1
answered on 28 Feb 2012, 01:34 PM
Glad you made it. With silverlight, this is the right way. 
Tags
General Discussions
Asked by
Ricky
Top achievements
Rank 1
Answers by
Hadib Ahmabi
Top achievements
Rank 1
Ricky
Top achievements
Rank 1
Share this question
or