rgansevles wrote:Patrick,
Can you show an example of a servoy method that uses this patched plugin?
I see you are collecting all data needed for the report and you are sending that to the server part of the plugin where the report is filled with this data.
I wonder how you determine which fields are required for the report.
Does this also support a report with grouping?
For instance a department report with the employees listed:
-- Sales
---- Anne
---- John
-- Marketing
---- Chris
---- Ellen
Rob
Hi Rob,
While reviewing the sample solution below, I just noticed a problem with the patch I submitted yesterday (it was running late, so I didn't see this one, sorry), you will find a new version attached, but if you prefer you can edit, in the JasperReportsProvider.java file, the lines 375,376:
- Code: Select all
} else if (obj instanceof SerializableTableModel) {
model = (SerializableTableModel)obj;
should read:
- Code: Select all
} else if (obj instanceof TableModel) {
model = new SerializableTableModel((TableModel)obj);
About your question: in the attached archive, you will find a very simple solution based on the "udm" sample database. This solution contains one method demonstrating the use of my patched version. You will also find the jasper report (compiled for jasper 3.0.0 and along with the source), that should show you how I achieved grouping in the report.
Basically, I first convert my foundset to a dataset with convertToDataSet(foundset, array), where the array contains the field I want to retrieve (also works with related fields), then convert this dataset to a TableModel, using dataset.getAsTableModel(), then call the plugin with this dataset. There really is only 3 lines of significant code.
On the jasper report side, you will see that I have created fields with the same name as the fields I put in the array (including the relation and dot when applicable, for example "contacts_to_companies.company_name"), and then I created a group based on one of these fields (in my case "$F{contacts_to_companies.company_id}"), that's it!
To be able to test it, I did create a source on the udm database and made a query retrieving the same data with the same fields name, but this step is not necessary if you know what you are doing.
Hope this answer your question,