0

マスターレポートは、List(parentList)を含むデータソースを使用します。このList(parentList)には、他のList(childList)が含まれています。このchildListは、DataSource(JRBeanCollectionDataSource)としてSubReportに渡されます。

このchildListには2つの列が含まれています。以下は、リストの表形式です。

<pre>TestString  | Date</pre>
<pre> abc | 01JAN12 </pre>
<pre> cdf | 31DEC12 </pre>
<pre> fgh | 08JUN12 </pre>

上記の表から、日付を比較して、この場合は最新のdate(ie) cdfを持つレコードの「TestString」値を取得する必要があります。

行またはレコードの比較は、JavaクラスではなくJasperレポートで行う必要があります。

これどうやってするの ?

4

1 に答える 1

3

あなたはJava側でそれをしなければなりません

あなたがpojo構造を持っているとしましょう

public class Parent{
    private List<Child> childList;
    ...
}

public class Child{
    String testString;
    Date date;
}

レポート生成を行うJavaメソッド内

...
List<Parent> parent = //method for getting datasource
List<String> testStrings = getTestStrings(parent);
...
//pass the list of testStrings to the report
//inside the report, create a parameter of type List
//pass list.get($V{ctr}) to the subreport where ctr is the current count of the subreport, make it start with 0

getTestStringsメソッドは次のようなことをする必要があります

private List<String> getTestStrings(List<Parent> parent){
    //loop through parent list
    //pull each child list then do the sort by date then get(0).getTestString()
    //put the value in a list
    //return the list
}
于 2013-02-08T02:35:18.000 に答える