group-byjasper-reports

Jasperreport how to reorder records while using groups


I'm using JasperReport and unfortuntately I cannot change the soruce code that makes the detail records.

My report has groups and seems that JasperReport process expect that records have been already ordered by group, otherwise a group can be repeated.

Is there any way to run a record reorder or force JR to order by grouping field in the jrxml? The report (jrxml) that it is the only thing I can customize for this project.


Solution

  • You can order the data source records by adding a sort field to the report:

    <jasperReport ..>
        ..
        <field name="FieldName"/>
        ..
        <sortField name="FieldName"/>
        ..
        <group name="GroupName">
            <expression><![CDATA[$F{FieldName}]]></expression>