开发者

iReports Grouping Bug - Multiple Occurrences?

开发者 https://www.devze.com 2023-04-13 00:30 出处:网络
I\'m am getting irritated with iReports. Problem is that I have a data set returning data for multiple customers and I want to use the \"Group Expression\" against the customer ID and have the report

I'm am getting irritated with iReports. Problem is that I have a data set returning data for multiple customers and I want to use the "Group Expression" against the customer ID and have the report lay out the Detail Tabs per customer.

I'm finding that, seeming randomly, where there is more that one data row for a customer iReports will generate two or more groupings (Sometimes it does what I expect and group all the customer data together), the field IDing the customer is the same and doesn't change.

Has anyone seen this before? To be honest I can't believe it is actually a bug, bu开发者_JS百科t something I've missed. Just much searching as yet to find a suitable result.


I think this is a data sorting problem.
The quote from iReport Ultimate Guide:

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


You can sort data in these ways:

  • in case using of Database jdbc connection datasource type you can add ORDER BY customerId clause to the report's query, where customerId - column name of field with customer id
  • in case using of File csv connection or something like this you can organize data sorting by adding sortField property for field to the report's template (jrxml file):
<jasperReport ...>
    ...
    <field name="customerId" class="java.lang.String"/>
    <sortField name="customerId"/>


  1. SQL Statement has ORDER BY?
  2. iReport group is grouped by customer_id?
0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号