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

Showstopper by Upgrade ReportBook to R2 2017

3 Answers 40 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
Thomas Sonnenschein
Top achievements
Rank 2
Thomas Sonnenschein asked on 28 Jul 2017, 08:59 AM

Hello,

  I try to update my Telerik Reports from Q2 2015 to R2 2017. With my report books I have massive problems to get the data into the report.

My code so far (working perfect in Q2 2015) for ReportBook creation:

ReportBook trbReport = new ReportBook ();
 
// Instances of Telerik Report for Report Book
TPage1Report reportPage1 = new TPage1Report;
TPage2Report reportPage2 = new TPage2Report;
 
// Add Reports to ReportBook
trbReport.Reports.Add (reportPage1);
trbReport.Reports.Add (reportPage2);
 
// Add Datasources to report pages
ReportDatasourceClass1 ds1 = new ReportDatasourceClass1 ();
ReportDatasourceClass2 ds2 = new ReportDatasourceClass2 ();
 
trbReport.Reports[0].DataSource = ds1;
trbReport.Reports[0].DataSource = ds2;

And in code behind of the Report itself (I have a Table in the Detail Section, which datasource should be a list in the Reports datasource):

private void detail_ItemDataBinding (object sender, EventArgs e)
{
    ReportDatasourceClass1 data = DataSource as ReportDatasourceClass1;
 
    // Set Datasource of Telerik.Reporting.Table in Report to List Property
    //  in Datasource of report  
    tTable.DataSource = data.List1;
}

 

This is not working anymore in R2 2017: The Table in the Report is empty and in the second page I have some graphs, which datasources are also set in DetailItemDataBinding, which are also empty.

 

The Reports Property of ReportBook is marked as obsolete, so I tried ReportSources.

Problem 1: ReportSources has no property "DataSource". My way to set the DataSource of my report pages is impossible.

Problem 2: The Parameters Section of the ReportSources entries are empty (not filled with the parameter lists from the Reports.

So I tried the following to fix that behaviour:

TPage1Report page1 = new TPage1Report ();
page1.ReportParameters["param1"].Value = param1Value;
page1.DataSource = page1DataSourceInstance;
trbReport.ReportSources.Add (page1);
 
TPage2Report page2 = new TPage2Report ();
page2.DataSource = page2DataSourceInstance;
trbReport.ReportSources.Add (page2);

 

Now in the DetailItemDataBinding my datasource is present, but in the rendered Report the List and Graphs still empty.

 

Has someone solved the ReportBook Datasource in 2017 R2 yet (I used this above method successfully since 2009)?

 

Greetings

  Thomas

3 Answers, 1 is accepted

Sort by
0
Katia
Telerik team
answered on 31 Jul 2017, 01:22 PM
Hi Thomas,

The changes that were introduced in versions after Q2 2015 were as following:

1. Optimization change in the report rendering algorithm that affects how each definition item property values are read and cached once the report rendering starts (R3 2013)
2. To allow better integration with Standalone Report Designer, ReportBook now has ReportSources property (R1 2017)

The changes that need to be made in your current code are:

1. Inside events you can only work with processing element, for example:
void report_NeedDataSource(object sender, EventArgs e)
{
    Telerik.Reporting.Processing.Report processingReport = (Telerik.Reporting.Processing.Report)sender;
    Telerik.Reporting.Processing.Table table = (Telerik.Reporting.Processing.Table)Telerik.Reporting.Processing.ElementTreeHelper.GetChildByName(processingReport, "table1");
     table.DataSource = newDatasource;
}

For more details and examples check Changes on items in report events are not applied KB article. 

You can also set the table's DataSource when creating an instance of the report, for example:
TPage1Report page1 = new TPage1Report ();
Telerik.Reporting.Table table = page1.Items.Find("table1", true)[0] as Telerik.Reporting.Table;
table.DataSource = newDataSource;
You can use methods of ElementTreeHelper Class to reach the inner report items.

2. Use ReportBook.ReportSources collection to add reports to the ReportBook, for example:
Telerik.Reporting.ReportBook reportBook = new ReportBook();
Telerik.Reporting.TypeReportSource typeReportSource = new TypeReportSource();
typeReportSource.TypeName = typeof(Report1).AssemblyQualifiedName;
reportBook.ReportSources.Add(typeReportSource);

In the above example, TypeReportSource is used. However, any of the available ReportSource objects can be added to ReportBook.ReportSources collection.

For more details check How to use ReportSource objects with ReportBook KB article.


I hope this information will help.
 

Regards,
Katia
Progress Telerik
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Feedback Portal and vote to affect the priority of the items
0
Thomas Sonnenschein
Top achievements
Rank 2
answered on 01 Aug 2017, 11:35 AM

Hello Katia,

thank you for your quick response.

I tried your suggestion and had some success with it:

  1. For the datasource of a table it works (with slightly problems, because may table is not a direkt child of the detail but in a panel and the Function "GetChildByName" finds only direct childs. So that I have to use "FindChildByName". But this gives me an array of controls, which is a bit annoying because the name of the controls in a report are unique and the function "FindChildByName" must not find more than one control).
  2. For my second report this aproach is completely unusable. I have to manipulate a Graph Control depending on the given data, but in the Processing Namespace there is no Graph control and when I cast to "DataItem" I can only set the datasource.

So I had to choose the solution, which is mentioned in the linked KB Article (Changes on items in report events are not applied), to switch off the property resolution optimization.

 

PS: In this KB Article is a big mistake. The Type "Telerik.Reporting.Configuration.ReportingConfigurationSection, Telerik.Reporting.Configuration" don't exists (Exception "DLL not found" and my MVC Application refuses to start. Instead I have to use "Telerik.Reporting.Processing.Config.ReportingConfigurationSection, Telerik.Reporting" to get a configuration section for the Telerik Reports in my web.config. Then the switch to deactivate the processing cache works fine.

Greetings

  Thomas

0
Katia
Telerik team
answered on 02 Aug 2017, 01:29 PM
Hello Thomas,

Note that in most scenarios the logic in report events can be replaced with bindings - check Modifying or Creating a report at Run-Time KB article for more detailed suggestions.

There can be many processing instances of a report item during report processing. For example, if textBox1 item is placed inside the detail1 section this section will be generated for each row from the report's data source.
If in some scenarios you need to reach the processing parent element you can use LayoutElement.ParentElement Property.

Regarding the error you receive, it seems that the project is not updated successfully. 
Telerik.Reporting.Processing.Config.ReportingConfigurationSection is obsolete and the correct approach is to use Telerik.Reporting.Configuration.ReportingConfigurationSection type of the configuration section as suggested in the mentioned KB article.
Test running the Upgrade Wizard and make sure CopyLocal properties of Reporting assemblies are set to true in VS properties grid.


Regards,
Katia
Progress Telerik
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Feedback Portal and vote to affect the priority of the items
Tags
General Discussions
Asked by
Thomas Sonnenschein
Top achievements
Rank 2
Answers by
Katia
Telerik team
Thomas Sonnenschein
Top achievements
Rank 2
Share this question
or