I am currently trying to group data together based on a field "type" using iReports 5.6.0. It seems to work but spreads the groups into different places see example below:
What happens
ID Name Location Type Cost
1 C1 FRA Car 2k
2 C1 FRA Car 2k
3 Transit USA Van 10K
4 Custom USA Van 20K
5 C2 FRA Car 4K
Expected Result:
Example Data
ID Name Location Type Cost
1 C1 FRA Car 2k
2 C1 FRA Car 2k
5 C2 FRA Car 4K
3 Transit USA Van 10K
4 Custom USA Van 20K
I wish the data to come out as the expected result below instead of groups seem to be split up (which I think is it the order data is fed into the report from the application)
I have tried using the keep together option but it doesn't seem to work in this situation.
When using grouping in jasper report to get correct output the data needs to already be ordered according to the group expressions used.
See: Grouping Data in JasperReports
You can achieve this by either:
order your datasource through query ORDER BY or if using custom datasource for example Collections.sort()
or
use the <sortField/> element in the report for example <sortField name="myField"/>.
In iReport IDE open the Report Query Dialog "edit query" and click the "Sort options..." button (bottom of interface)
In JasperSoft Studio open the dataset and query dialog, find the tab "Order" at the bottom and add your field(s)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With