I want to display elements horizontally (in one "line"). I'm imagining this problem like a table with one row and dynamic number of columns. Each cell in this table contains the same subreport but with different data source.
At the beginning I was trying combining a component list and the subreport. But it turned out that the list component doesn't support a horizontal layout. I read somewhere to use the crosstab instead. But when I'm trying to insert the subreport into a measure cell iReport displays a message that I can't do it. So what can I do?
@bchetty : Sorry I chose to answer rather than comment as I do not have enough reputation to do so. The solution posted by you works fine but it leaves the report layout pretty Not Ok. I had a smilar requirement where I kept the columns size as 20 but then I can never predict that it would not cross 20 in some query. Again if only three values are fetched from the query for the columns then the remaining column spaces remain empty and do not give a good layout for the report generated.
I read in iReport ultimate guide book that if the List is being used as a sub report and the printOrder "horizontal" we can get the effect of dynamic columns. But I guess this is just an "effect" and not actually dynamic columns as the columns size has to be fixed to some value greater than 1.
I am at wits end trying to achieve this but I guess I might have to give up. Crosstab can't come to rescue either as it is limited by two row groups and two column groups. But the report has other fields which must be printed too alongwith the dynamic columns. Printing a sub report data horizontally
Based on your above comment, I would say that it is not that difficult to print a list of elements horizontally. A List component is basically a subreport. So, you could also create a custom List component, which prints a list of elements horizontally. All you need is to create a new report without any margins, set it's "Print Order" to "Horizontal" and set the number of columns as per your requirements. You could then embed this report as subreport in some main report and print elements horizontally.
Based on your requirements, you can set the report and text-field sizes accordingly. Here's the screenshot for that report I created:
And here's the sample jrxml document that I created: