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 conta
@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:
<?xml version="1.0" encoding="UTF-8"?>
<jasperReport xmlns="http://jasperreports.sourceforge.net/jasperreports" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://jasperreports.sourceforge.net/jasperreports http://jasperreports.sourceforge.net/xsd/jasperreport.xsd" name="report name" columnCount="5" printOrder="Horizontal" pageWidth="595" pageHeight="842" columnWidth="119" leftMargin="0" rightMargin="0" topMargin="0" bottomMargin="0">
<property name="ireport.zoom" value="1.0"/>
<property name="ireport.x" value="0"/>
<property name="ireport.y" value="0"/>
<background>
<band splitType="Stretch"/>
</background>
<title>
<band splitType="Stretch"/>
</title>
<pageHeader>
<band splitType="Stretch"/>
</pageHeader>
<columnHeader>
<band splitType="Stretch"/>
</columnHeader>
<detail>
<band height="20" splitType="Stretch">
<textField>
<reportElement x="0" y="0" width="100" height="20"/>
<textElement textAlignment="Center" verticalAlignment="Middle"/>
<textFieldExpression><![CDATA[$F{field}]]></textFieldExpression>
</textField>
</band>
</detail>
<columnFooter>
<band splitType="Stretch"/>
</columnFooter>
<pageFooter>
<band splitType="Stretch"/>
</pageFooter>
<summary>
<band splitType="Stretch"/>
</summary>
</jasperReport>