Displaying a Tree Structure in Crystal Reports - crystal-reports

Does anyone know of a way to represent a tree structure in Crystal Reports?
My big issue is that I don't know the depth of the tree. It is represented in a database table with a simple "childId -> parentId" relationship.
A perfect example would be to open Windows Explorer, and look at the directory tree on the left side. If anyone knows a way to represent that tree, then it'll work for what I need to do too.
My initial attempts have been:
1) to programatically (in C#) add Groups to the report. Unfortunately, you can't create a new instance of the Group class and add it to the Groups collection.
2) recursively nest the same report into itself for each level. In other words:
mainReport
subReport
subReport
subReport
subReport
subReport
subReport
etc...
Unfortunately, SubReports can't contain SubReports.
I really don't want to just add X number of groups into a report and hide the ones I don't need, because I'd have to add a fixed number of nested groups, but technically the data design can support an infinite depth, even though in practice we see up to about 5 levels of depth.
So, any other ideas?

Crystal XI added hierarchical grouping. You'll find this under the Reports menu. I put together a quick org chart report with n-level depth using this. The database table is like:
id
name
managerId
In the Crystal Report, you select these columns, group by id. Then under "Hierarchical Grouping options" menu under Reports, check off "Group Data Hierarchically", parent Id managerId, and indent appropriately.
The output is like the tree you described in Explorer.

Related

Report vertical layout

I have existing report w/ "groups" for Total/Directs/Warehouse/Credits that span horizontally. I need to now stack these groupings vertically. What is the best way to do this in CR? I am used to SSRS, Excel, PowerBI, etc. Crystal Reports is much less intuitive than those tools.
Do I need some kind of funky nested groups? Sub reports? How should we approach this? We assumed it would be a pretty simple formatting/layout change. But it looks like it's actually quite complex to do this.
Original:
How it needs to be re-worked:
If the entire table you're showing is in a Footer, you can just add 3 new footer sections and duplicate the table in each (removing any columns you don't need.) Just right click the relevant section and Insert Section Below.
Otherwise you'll need to use subreports. But since you have the columns already configured, all you really have to do is:
Save 4 subreports, Total, Directs, Warehouse, and Credits. (Just save a copy of your existing report, and delete everything that doesn't need to show up in Total. Rinse and repeat.)
Import each and add the parameters as subreport links
Give them each their own section

Jasper Report group subreports using columns

I have a master report (using iReport 5.0.4) with a subreport that uses grouping by a field called "Group Number" (sorry, but that is the actual column name).
My report works fine when there are more than one group, but it generates each group result scrolling down the page vertically.
I would like to be able to have each group go across vertically, but when I tried using columns, it simply forces each group's data into columns, and not the entire group 1, followed by group 2 in the next column, etc.
There can be up to 8 groups, so I was hoping not to have to create 8 individual sub-subreports with a "print when" expression to show/hide them.
Can anyone tell me if this should be possible?
Thanks,
Mitch
I think making subreports is the easiest and obvious way. But if you want to make it in other way, I can only suggest to use scriptlet, and form dataset manually (Transpose it).
Another suggestion is when you generating report directly from database (i.e. passing connection into jasper) you can modify query and transpose the data (PIVOT table).
Anyway provide more info about your case. I will try to help you.

Subreport Inner-join showing different results than same Main report inner-join

Crystal Reports is used to create templates for another application in my case. A value is passed from the other application to a specific table, which I can then, in crystal, use with inner joins to other tables to specify the values on the rest of the report.
This has worked well in situations where I have not being using subreports. In my main report, I have 4 tables inner joined, and they are correctly being passed a certain value from this program.
My problem lies with attempting to create a coverpage for this particular report. I needed a detail section on the coverpage, so I looked to creating a subreport on the report header of the main report. I used the same tables in the subreport itself with the same inner joins. It receives extra values. This is the exact inner join design with the same tables from the main report, yet it is showing different results.
Does anyone have a solution to this? I am particularly new to crystal reports, and have just avoided subreports to avoid deeper complication. I believe I may just be able to pass the criteria value from the main report through a shared variable or parameter as an alternative to my current attempt, but I am not sure how.
Thanks.
It sounds like you are taking the right approach by using a subreport. You did add the parameter to the subreport and linked it through from the main report?
I suggest you view the SQL query for both the main report and subreport to identify the discrepancy.

Multiple unrelated in JasperReports

I am using iReport with JasperReports. I want to include multiple subreports that have unrelated sql queries. I would like to be able to put these all on one report.
The problem I am facing is that when I leave the master report sql query empty, none of my subreports have any data. There isn't really anything that the master report sends to the subreports since they are unrelated. Basically how do you throw multiple unrelated reports together into one report.
In order for the Detail Band to show, you will need to fill the main report query, even if its just a dummy query, like say:
SELECT 'a' FROM DUMMY
This will make the Detail band appear, and with it all the sub reports.
Otherwise, if you don't want to use the Detail Band, you have the option to view the other bands without using a query. From Edit menu, choose Report Properties, under More... tab, set the flag When no data to All Sections, no detail

Multiple groups in Crystal Reports

How can I use multiple groups — which are not nested — in Crystal Reports?
A little Example of what I want to do:
-hire car header
--rentals header (group)
---rental from 01-02-2008 to 01-06-2008
---rental from 01-08-2008 to 01-09-2008
---rental from 01-12-2008 to 01-15-2008
--rentals footer
--repairs header (group)
---repair from 02-02-2008 to 02-05-2009
--repairs footer
-hire car footer
hire car is the normal report, and rentals and repairs are the groups. The groups are not nested. My current problem is that I can't really create something like that, and I can't change the structure to solve this problem...
I'm totally new to crystal reports.
That's a good question. I would call that a double one-to-many. You have "hire car" which can have many rentals and/or many repairs.
One solution would be to use two sub-reports for the rentals and repairs.
Another solution would be to union together the repairs and rentals. Then have crystal group on the column that specifies if the row is rental or repair data. You would also have to show/suppress the correct labels, fields, etc. This get's very clunky so your best bet is to go the sub-report route.