We have been work hard to get running with dynamic reports. I admit that Telerik solution for report is pretty cool.
There were are following options to get our work going:
- Make use of “Table” API in Telerik Report
- Simple approach of making fields and align them properly
Option 1, failed to great extent in terms of loading heavy amounts of data. (1600 rows, between is not heavy). Researched on it today and submitted ticket to telerik 448457. With that i hope they fix the issue of table rendering. There is something seriously wrong with their approach.
That being said, i really like the support they give to people for their solution, help system and follow-ups are quite good. With Video tutorials – it makes life easier when you get stuck into some problem.
Now, we went for other (simpler) approach.
Rough flow of information through the silverlight application
Silverlight -> WCF (ReportService.svc) -> Report_NeedDataSource -> Build Report Columns, and provide the data source itself.
Now, Passing information of the context, connection string and running or making query for report posts lot of questions
- Security
- How to pass back and forth
- Fields to display
With that in mind, we used simple parameter passing with some token that tells us where to look for information. This allow us to not send any connection string infomation though the wire.
// important
((System.ComponentModel.ISupportInitialize)(report)).BeginInit();
//get details section, you can get name of the detail section by looking at definition of
//InitializeComponent
DetailSection detailSection = report.Items[“detail”] as DetailSection;
//set height
detailSection.Height = Unit.Inch(0.2);
String[] fields = ….
foreach (String fld in fields)
{
//Fields
Telerik.Reporting.TextBox numberTextBox = new Telerik.Reporting.TextBox();
Telerik.Reporting.TextBox grpHeaderLabel = new Telerik.Reporting.TextBox();
numberTextBox.Left = Telerik.Reporting.Drawing.Unit.Inch(counter);
grpHeaderLabel.Left = Telerik.Reporting.Drawing.Unit.Inch(counter);
//Your Logic for alignment or any other goes here…
//Add them to respective sections
detailSection.Items.Add(numberTextBox);
grp.GroupHeader.Items.Add(grpHeaderLabel);
counter += 1D;
}
//Make Data Source
Telerik.Reporting.SqlDataSource dataSource = new Telerik.Reporting.SqlDataSource();
//connection code goes here…
//select query
dataSource.SelectCommand = “Select fields from table “;
report.DataSource = dataSource;
//pretty important
((System.ComponentModel.ISupportInitialize)(report)).EndInit();
Ok, thats all you need to do.
Note: Create a Blank Report for Telerik.Reporting and then write code in there.
Thanks,