This video shows how to control the sort order of a Jasper Reports Crosstab using a Parameter.
Java Class Notes
To use the Java class mentioned in the example, create a toplevel directory like C:/classes. Next, add the required folder structure for the Java class (create folders for each path elements): com/bekwam/blog/sort. Finally, download the Java class file from the Bekwam web server:
DynaSortComparator.class
Alternatively, compile the Java class available here: DynaSortComparator.java.
Next, point iReport to the toplevel class folder you created. DO NOT SET THE CLASSPATH TO THE com, bekwam, blog, or sort subfolders.
Setting Classpath in iReport |
Possible Errors
The .class file I provided works only with Java 1.7. I'll put up a backward-compatible version, but you can resolve this yourself by compiling your own version if you have a JDK available.
To check if a JDK is available type 'javac version' at a command prompt.
Here are the instructions on compiling DynaSortComparator.java for your version.
1. Save the source file in the "sort" folder created for the class file. (com/bekwam/blog/sort)
2. Change into the sort folder
3. Run the command > javac DynaSortComparator.java
This will replace the downloaded class file with one specific to your system.
Thanks for this great tutorial. I wrote you at gmail, if you could help me, it would be great.
ReplyDeleteKalina wrote about ordering a set of columns not involved in the crosstab. These are classifier columns that gave the crosstab columns more context. For example, a report with classifier columns Dept and Employee and then a list of Item columns. I suggested creating multiple reports, one report for each classifier column. This would produce one report that is Dept/Employee/Item1...ItemN and one report Employee/Dept/Item1...ItemN.
DeleteThis has the downside of hampering maintenance because there is now more similar code to maintain. However, if you're close to a deadline, this may be something you can use if the dynamic behavior isn't readily apparent.
谢谢,帮我解决了问题,哈哈
ReplyDelete