You can make a multi-level group report by selecting a field as grouping criterion for the report. However, because the grouping criteria are definite, if you want to group several times according to different grouping criteria but based on the same table in the database it is cumbersome. For example, you want to make three employee list reports with different grouping criteria, the first one is grouped by their first name, the second one is by the hire date and the third one is by their salary, then you have to repeat the steps of setting query, selecting fields as grouping criteria, and so on, which is not efficient.
For this case you can use the Dynamic Grouping feature of JReport Designer, which means grouping criteria is a dynamic process. You don't need to repeat the same steps to make multiple reports with different grouping criteria. You can just predefine a parameter using String value type and add it to the group list. Then when you run the report, the parameter dialog prompts the end user to select a field to group by. All the acceptable group by fields are listed in a drop-down list. You can select any of them as grouping criterion.
Assume that you have created a table based on the EmployeeInformation query in the SampleReports.cat catalog, which displays the fields Name, Home Phone, Employee Position and Salary, and applies the Neutral style.
To apply the dynamic grouping conditions, follow the steps below:
To group the data by hire date or salary, the end user would need to select Hire Date or Salary from the drop-down list.