Print child collections next to each other
Apologies if this is a foolish question, but I am just evaluating FastReport and am trying to work out what it is capable of.
I am passing a business object to FR.NET. The business object has four members which are collections of data:
Parent
-> Child1
-> Child2
-> Child3
-> Child4
I want to display the data in the children in tables next to each other. I.e. I want to see four tables side-by-side on the page.
I have not been able to get this to work. It seems that I need to put everything in a data band which maps to the collection I want to iterate over. I.e. if I put a table in a data band which is mapped to [Parent.Child1] the table will populate with the entire contents of Child1.
I would have thought that if I mapped a single data band to [Parent], and put four tables in the band for each of the child collections then the report engine would be able to work out how to populate them but this does not seem to work. The tables are just populated with the first item of each collection (i.e. the tables have only one row each).
I guess I can pre-process the data before I pass it into the report so it looks like what gets printed (i.e. the Parent will have a collection of Rows, each one of is a collection of values for each cell), but I am surprised that I have to do this.
Am I missing something here? Is it possible to pass in hierarchically structured data (i.e. a parent with children) and have the data print in tables next to each other?
I have attached a Visual Studio solution which demonstrates what I am trying to achieve. Hopefully someone can tell me that I am missing something obvious.
Thanks in advance for your help.
I am passing a business object to FR.NET. The business object has four members which are collections of data:
Parent
-> Child1
-> Child2
-> Child3
-> Child4
I want to display the data in the children in tables next to each other. I.e. I want to see four tables side-by-side on the page.
I have not been able to get this to work. It seems that I need to put everything in a data band which maps to the collection I want to iterate over. I.e. if I put a table in a data band which is mapped to [Parent.Child1] the table will populate with the entire contents of Child1.
I would have thought that if I mapped a single data band to [Parent], and put four tables in the band for each of the child collections then the report engine would be able to work out how to populate them but this does not seem to work. The tables are just populated with the first item of each collection (i.e. the tables have only one row each).
I guess I can pre-process the data before I pass it into the report so it looks like what gets printed (i.e. the Parent will have a collection of Rows, each one of is a collection of values for each cell), but I am surprised that I have to do this.
Am I missing something here? Is it possible to pass in hierarchically structured data (i.e. a parent with children) and have the data print in tables next to each other?
I have attached a Visual Studio solution which demonstrates what I am trying to achieve. Hopefully someone can tell me that I am missing something obvious.
Thanks in advance for your help.
Comments
I had the same problem.
I managed to resolve this with using subreports.
If you have master-child relation in datasource, in main report page data band you can create subreport in which you create data band with your subcollection as data source.
To create data in one row you can use Column (Column.Count) property in Data Band to show data side by side.
In your situation you must create 4 subreports in one data band.
Hope it helps.