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

Best Approach for Hierarchical Folder Report

3 Answers 192 Views
Report Designer (standalone)
This is a migrated thread and some comments may be shown as answers.
Wardeaux
Top achievements
Rank 1
Wardeaux asked on 31 Aug 2020, 07:16 PM

I need a series of reports that display folder information in a hierarchical layout (undeterminate number of folder level parents/children) so i need to find a way to create a report that presents each level and then its children recursively, such as a recursive BandedReport or possibly a Subreport would do...
- Data is retrieved from an SQL database table in a self-referencing datatable(the Folder.ParentID points to another folder record with the same Folder.FolderID. 
- I design the Reports in the StandAlone designer.
- We need them to be "self-processing"... that is, apart from setting parameters being passed from the calling Winforms Application, there should be no "additional processing" or "value setting" or "business logic" from the calling application. We need it to be truly "set parameters and call RefreshReport()" and let it go... This is so that we (AND our clients) can add reports like these to our application without needing to change application code or needing custom programming.

I have looked at and run the project from 2013 "Recursive HierarchyReporting" (https://www.telerik.com/forums/recursive-hierarchy-reporting) and found it somewhat useful except 1) it processes the selection of the subreports within the code class and 2) it uses a dataobject hierarchical layout within the data structure rather than a flat table of records that self reference.
can you point me to some more recent examples of how to accomplish the hierarchical report from a self referencing SQL datatable query?
many thanks!!

3 Answers, 1 is accepted

Sort by
0
Accepted
Todor
Telerik team
answered on 03 Sep 2020, 03:34 PM

Hello Wardeaux,

I noticed that you have opened a support ticket with the same requirement, and I have answered there with samples attached. For the benefit of our community, I will summarize the suggested approaches also here:

1. Using DataSource with flattened data - see HierarchyFromFlatData.trdp.

The report has a JsonDataSource assigned and displays a static field - ChildItem, and a subreport that references the same report document. There is a Report Parameter with the initial value set to nothing (Null). The SubReport item passes as ReportSource->Parameters value the field ChildItem of the parent report. The idea is that we will filter the report data based on this parameter, i.e. will display only those items from the data source that have as ParentItem the current ChildItem in order to structure the correct hierarchy. Here is the Report Filter:

Expression					|	Operator	|	Value
= IsNull(Fields.ParentItem, '1')	|	=		|	= IsNull(Parameters.Parent.Value, '1')

The purpose of the IsNull functions above is to allow the comparison when the current ParentItem doesn't have a parent (it is Null), like in the case of the first data item - see the JsonDataSource data.

2. Using DataSource with nested collections - see .HierarchyFromNestedCollections.trdp

Again we use one report that references itself through a SubReport item. The report has a DataSource assigned (the JsonDataSource with hierarchical  nested data collection) and a DataSource assigned with Bindings through the following Expression:

Property path	|	Expression
DataSource	|	= ReportItem.Parent is Null ? ReportItem.DataSource : ReportItem.Parent.DataObject.List

This way, if the Report doesn't have a parent, like in the case of the main report, the default DataSource will be the JsonDataSource, otherwise, the List field of the parent report will become the new subreport data source.

The SubReport item has a ReportSource set directly, and with the following Binding:

Property path		|	Expression
ReportSource.Uri	|	= Fields("List") is Null ? Null : "HierarchyFromNestedCollections.trdp"

The expression modifies the ReportSource so that when there is no more field "List" in the parent report DataSource the SubReport not to be rendered, which will be the bottom of the recursion. The direct setting of the ReportSource property is needed in order to create the ReportSource object before modifying its Uri property with the Binding.

Regards,
Todor
Progress Telerik

Five days of Blazor, Angular, React, and Xamarin experts live-coding on twitch.tv/CodeItLive , special prizes and more, for FREE?! Register now for DevReach 2.0(20).

0
Wardeaux
Top achievements
Rank 1
answered on 03 Sep 2020, 03:56 PM
Awesome! Thank you so much, you guys ROCK!
0
Nima
Top achievements
Rank 1
Iron
answered on 28 Mar 2022, 11:32 AM

Hi Todor, 

I have a Hierarchical Nested Data that I tried to present in my report. But it does not work as it should for me.
I followed steps that explained here: https://docs.telerik.com/reporting/knowledge-base/hierarchical-report-from-nested-data

I get my list in two different pages, first page includes all the nodes, but the last node and second page lists all my last nodes as a flat data.

I am working on this for almost a week with no success.

I used your sample template as an example to follow and I was super frustrated that how come it works prefect in "preview" with your template but when I try to render my data in my template it looks messy. But then I noticed even in your sample template the result looks correct only in "Preview" mode of standalone designer but when I choose "Print Preview" or any of the "Export" options, data presents in two pages as well (Exactly like mine). 

Can you please help me to fix this. We are trying to evaluate using Telerik reporting and this is basically the last check we need to do before purchasing it.  

I attached two picture that define this behavior. 

We are using Telerik Reporting designer version 15.2.21.915

To generate pdf-documents through the Telerik Reporting Component I use the following steps:
UnpackageDocument
Set datasource
Update all relative paths for subreports
RenderRepor

Thanks in advance

/Nima

Todor
Telerik team
commented on 31 Mar 2022, 08:21 AM

Hi Nima,

Based on the screenshots and the description, it seems that you see horizontal pagination in the PrintPreview and other physical export formats.

The reason for this is that the final report becomes wider than the available paper width. The latter may be set in the Report > PageSettings > PaperKind/PaperSize property. In order to accommodate all the content, the Reporting engine performs a horizontal page break, introducing a new physical page.

The observed behavior is expected. In order to avoid it, you need to assure that the total width of the report can fit within the available page area. That said, you may either decrease the report width or increase the paper width. You may check the article Understanding Pagination for more details.

Nima
Top achievements
Rank 1
Iron
commented on 05 Apr 2022, 09:11 AM

Hi Todor, 

Thanks for your reply, setting size for sub report solved my problem. 

I have another issue regarding Hierarchical Nested Data, I would like to have an additional column that present the prices for my products but since I am using nested sub-report, the size of my parent element gets bigger and bigger with each child that pushes away my price column. 
I searched a bit in your forum and I found a solution that suggest to set anchoring property for my sub-report- which I did, now my column looks great but the start of each node depends on the number of nested child shifts to the left,
Im not sure if I expressed the issue in an understandable way but I attached some screenshots for before and after applying anchoring to my sub-report, hopefully they help to understand it better. As well as a zip file with my report templates.

Before applying the anchoring:

After applying the anchoring right:
 Best Regards

/Nima

 

Todor
Telerik team
commented on 08 Apr 2022, 08:20 AM

Hello Nima,

You may use Anchoring to both Left and Right for the SubReport item. This worked locally with your reports. Here is a link to a screenshot with the result.

 

Tags
Report Designer (standalone)
Asked by
Wardeaux
Top achievements
Rank 1
Answers by
Todor
Telerik team
Wardeaux
Top achievements
Rank 1
Nima
Top achievements
Rank 1
Iron
Share this question
or