As i understand it, we can group the dataset by column in jasper report. But this requires the grouping process to be done by jasper report itself.
For example, with these item purchased dataset:
1. Peanut Butter, qty is 100, priced at 1000
2. Peanut Butter, qty is 10, priced at 1200
3. Blueberry Jam, qty is 20, priced at 3000
If i were to tell jasper to group by item name, and then i pass my dataset to jasper as a list of map objects like:
[
{ name: 'Peanut Butter', qty: 100,price: 1000},
{ name: 'Peanut Butter', qty: 10,price: 1200},
{ name: 'Blueberry Jam', qty: 20,price: 3000}
]
And the rendering output of jasper would become:
Peanut Butter
100 1000
10 1200
Blueberry Jam
20 3000
What if i want to do the grouping process in the db, even if it means doing many queries, and pass the already-grouped-datasets (including nested grouping) to jasper report to fill and render it as 'grouped' column ?
So my query and grouping in the db will procuce a dataset that would look something like a map, with the key is the 'grouped' column[s], and the value is the Map of the records, something resembling this:
{
Peanut Butter: [
{ qty: 100,price: 1000},
{ qty: 10,price: 1200}
],
Blueberry Jam: [
{ qty: 20,price: 3000},
]
}
This dataset is then passed 'somehow' to the jasper report engine, and also telling jasper to group by item. My expectation of jasper would render the output the same way, but it 'skips' grouping the data, and just use the 'grouped' dataset i passed.
This way i can make use of my db to do the querying and grouping, yet still preserve the group rendering in the report output. With jasper not sorting, grouping data in-memory, i also expect the report filling process to be faster.
I have taken a peek at JRDataSource, but seems like i cannot override the data source impl for the 'grouped' data, or somehow passing the already-grouped-data, so im wondering whether this is possible to achieve.