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

Path to SubReport fails (and ExternalStyleSheet also)

4 Answers 533 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
Heiko
Top achievements
Rank 1
Iron
Veteran
Heiko asked on 11 Apr 2015, 11:49 AM

Hi!

In my solution all reports are created with the ReportDesigner and saved as external .trdx files. The files reside at runtime in a common server-directory available to all workplaces. The "path-to-reports" is in the app.config of the main exe and it is no problem to load these .trdx file with a generic method using the ReportXmlSerializer. But two problems occur:

First, the ReportViewer (WPF, version Q1/2015) tries to load all subreports from the \bin\Debug directory of the main exe file, not from the directory where the main report is in. There is no "SubReports" collection in the report itself, instead I have to recursively search all Items for an object of type SubReport and set the "path-to-reports" which is very annoying. Is there another solution?

Second, the above also applies to external Stylesheets which are located in a subdirectory of the reports directory.

Regards
Neils

4 Answers, 1 is accepted

Sort by
0
Nasko
Telerik team
answered on 15 Apr 2015, 01:05 PM
Hello Neils,

When using a .trdx file with a UriReportSource the relative path to the sub-reports will be based on the location of the .trdx file.
However, if you deserialize the .trdx to a report object and use it with an InstanceReportSource the path to the sub-reports  will be relative to the application root directory (\bin\Debug in your case).
In the second scenario you will need to iterate recursively through all of the items in the report and change the ReportSource property if the item is of type SubReport.
Another solution is to embed the sub-reports in the main report in XML format.

The same path resolving mechanisms apply for the external stylesheets.

Regards,
Nasko
Telerik
 

See What's Next in App Development. Register for TelerikNEXT.

 
0
Heiko
Top achievements
Rank 1
Iron
Veteran
answered on 18 Apr 2015, 01:01 PM

Using ReportBook is not possible with UriReportSource, you have to deserialize the .trdx file to a report object in order to add it to a ReportBook. See this thread: http://www.telerik.com/forums/add-urireportsource-to-reportbook.

It would all be so easy if there was some kind of "here-you-find-all-your-report-files" property somewhere... So what is the

SOLUTION?

0
Nasko
Telerik team
answered on 22 Apr 2015, 12:45 PM
Hello Neils,

Unfortunately there is no such property. The solution is to iterate recursively through all of the items in the report and change their ReportSource property if the item is of type SubReport.
Another solution is to embed the sub-reports in the main report in XML format (XmlReportSource Class).

Regards,
Nasko
Telerik
 

See What's Next in App Development. Register for TelerikNEXT.

 
0
Trent
Top achievements
Rank 1
answered on 13 May 2017, 04:10 PM

We have several reports that also use the deserialize method. These reports are all stored in their own subfolders by language, client, etc. In the parent report, we added a parameter Path. Each of the parent report subreports then have the subreport report source set as: (URL or File option)

= Parameters.path.Value + "Subreport1.trdp"

When we call our to generate our reports, we are specifying other parameters, so it is just one more piece to send the pathing information to the report object.

mainReport.ReportParameters("path").Value = path

We do not have to do any recursive looping using this method. Hope this helps. (remember to decide if you are sending the trailing back slash in the parameter \ or adding it to your report source e.g. "\Subreport1.trdp")

Tags
General Discussions
Asked by
Heiko
Top achievements
Rank 1
Iron
Veteran
Answers by
Nasko
Telerik team
Heiko
Top achievements
Rank 1
Iron
Veteran
Trent
Top achievements
Rank 1
Share this question
or