IReports Grouping Bug - a few cases?

IReports annoys me. The problem is that I have a dataset that returns data for several clients, and I want to use the "Group Expression" in relation to the client identifier, and in the report you will find the "Details" tabs for each client.

I find it seeming random when there is more that one row of data for the iReports client will generate two or more groups (sometimes this does what I expect and group all the client data together), the IDing field of the client is the same and does not change .

Has anyone seen this before? Honestly, I can’t believe that this is actually a mistake, but I missed something. Enough searches to find a suitable result.

+6
source share
2 answers

I think this is a data sorting problem.
Quote from the iReport Ultimate Guide :

JasperReports groups records by evaluating a group expression. Each time the value of the expression changes, a new instance of the group is created. The engine does not sort records (unless explicitly), so when we define groups, we should always take care of sorting records. That is, if we want to group a set of addresses using a country, the records that we select for the report should already be ordered by the country. It’s easier to sort data using an SQL query using the ORDER BY clause. When this is not possible (that is, when retrieving records from an XML document), we can request JasperReports to sort the data for us. This can be done using the sort options available in the query window.


You can sort the data as follows:

  • if you are using the jdbc database data source type, you can add the ORDER BY customerId to the report request, where customerId is the name of the field column with the client identifier li>
  • if you use File csv connection or something like this, you can organize the data sorting by adding the sortField property for the field to the report template (jrxml file):
 <jasperReport ...> ... <field name="customerId" class="java.lang.String"/> <sortField name="customerId"/> 
+8
source
  • SQL Statement has ORDER BY ?
  • Is iReport grouped by customer_id ?
+3
source

Source: https://habr.com/ru/post/899242/


All Articles