Senin, 14 Februari 2011

Kismiss Dynamic Grouping

Kismiss provide one powerful feature, dynamic grouping. We can group field dynamically as the user want. We just passing the field to be grouped, kismiss will generate the report based on the field group chosen.

When using dynamic grouping, we need not to declare grouping in JavaBean class, but it will be defined outside the class.

Then our “Employee.java” will be :


@Kismiss(name = "Employee")
@Header
@Detail
public class Employee {
...
}



We don't need to define “Group” tag anymore.

Before we call the report generate method, we need to define our field group. Our code will look like :

KismissReport report = KismissReport.getInstance();

HashMap<String, Object> params = new HashMap<String, Object>();
params.put(ReportFactory.TITLE, "TEST KISMISS REPORT");
params.put(ReportFactory.INFOTITLE, "Report");
params.put(ReportFactory.REPORT_NAME, "employeeTest.pdf");
List<Calculation> calculations = new ArrayList<Calculation>();
Calculation calculation = new Calculation("capacity", CalculationType.Sum, "#",  "Sum Capacity", VerticalAlignment.Middle, HorizontalAlignment.Right);
calculations.add(calculation);
com.softtech.kismiss.access.Group group = new com.softtech.kismiss.access.Group("firstName", calculations, 20, 20);
group.setCalculationPrintType(CalculationPrintType.Complete);

report.generateAnnotatedPdfFiles(Employee.class, employees, "D:/Personal/Test/", params, group);

By declaring field in code, we have flexibility to define field group dynamically, only by passing the name of field to be grouped and calculation that included to that group.

In the example above, we can see that the report group by “firstName” and calculate the “capacity” with “Sum” CalculationType.


Tidak ada komentar:

Posting Komentar