0

I recently converted a JasperReport to use the XMLDataSource instead of getting the data from the DB. This was done for performance reasons.

One of the requests was to group certain records together.

I thought I had it working, but this was because my records that were grouped, followed sequentially in the XML file I used to test. So they were already "grouped/ordered" in the XML.

Now that the report is being used in a Live environment, we have picked up that the grouping is not actually working.

After doing some searching and reading, it seems that this cannot be easily done. Because we cannot sort the records from the XMLDataSource.

So my question: Is there a way to sort/order the records from the XMLDataSource so that they will correctly group, without using a XSLT.

I only want to transform the XML as a last resort. Hoping there is another way I can do it.

JBotha
  • 42
  • 1
  • 3
  • 9

1 Answers1

0

Why you can't use sort inside iReport? see this for example

sanBez
  • 933
  • 1
  • 8
  • 18
  • Thanks sanBez, I was trying to stay away from iReport, as it introduced other issues last time I used it. I followed your advice though, and sorted by the field I want. But now I am seeing the following error: "net.sf.jasperreports.engine.fill.SortedDataSource cannot be cast to net.sf.jasperreports.engine.data.JRXmlDataSource" This is on one of the subreports. Any ideas? – JBotha Apr 25 '13 at 11:07
  • Old thread but might be useful for someone... JasperReports wraps the JRXmlDataSource in a JRSortableDataSource, which means the line above yields a ClassCastException. I haven't found a good work around for this. – Jeremy Bunn Dec 05 '18 at 21:58