1. Business Requirement:
End users should be able to select any combination of columns to group by, the more columns they choose, the more columns need to be displayed.
So, the number of columns on the report page is not fixed, instead it's dynamic, on user's demand.
2. Solution
Refer to R1. In short, make use of Table component and Print When Expression. we can hide columns gracefully in Jasper Report.
3. Further: Why Not Crosstab
Crosstab is not appropriate for this business scenario, though its columns is dynamic as well. We need to display group-by column name on the table header, rather than group-by column value.
Reference:
[1] http://diethardsteiner.blogspot.hk/2012/10/jasper-report-gracefully-hide-columns.html