Search code examples
jasper-reports

Multiple Band in a Single Row in Jasper


Is it possible to obtain this kind of layout with this record in jasper and how to do that?

color_table

id | color_group | description
1  | primary     | the first
2  | secondary   | the second
3  | tertiary    | the third

color_table_details

color_table_id | color
1              | red
1              | blue
1              | yellow
2              | orange
2              | violet
2              | green
3              | etc

What layout i want is below.

id       color group       description           color
1          primary           the first           red
                                                 blue
                                                 yellow
2          secondary         the second          orange
                                                 violet
                                                 green

Solution

  • I solved that with the following solution:

    1. Added report group to the report
    2. Added new variable with type of string (var_name)
    3. On the variable expression property of the variable,
        $V{var_name} == null || ${var_name} == ""
        ? "1"
        : ${var_name} + ", 1"
    4. Set the reset type of your variable to **Report** and its reset group to the report group you created at step 1
    5. Then on your report layout, edit the text field expression of your id, color group and description to the following
        $V{var_name} == "1"
        ? ${field_name}
        : ""