How to properly use nested tables or lists in Birt report using xml as datasource

Viewed 21

I'm trying to build a Birt report which has a table element and a list as a table row. The data source I'm using is an xml file. The structure of the file reminds the following

<invoice>
    <orders>
        <order>
            <order_no>1<order_no>
            <total_price>43</total_price>
            <items>
                <item name="name1" order_no="1"/>
                <item name="name2" order_no="1"/>
            </items>
        </order>
        <order>
            <order_no>2<order_no>
            <total_price>52</total_price>
            <items>
                <item name="name3" order_no="2"/>
                <item name="name4" order_no="2"/>
            </items>
        </order>
    </orders>
</invoice>

where item elements have an attribute, which I use to be able to filter items by their parent. I have separate datasets for both orders and items, and the dynamic text for the inner list (items) looks something like

if(row["order_no"]==row._outer["order_no"]){
    row["name"];
}

The result is almost what I need, except for the fact that there are unnecessary empty lines in each outer table row which seem to be equal to the number of the total rows in outer table. The table looks something like this:

-------------------
|order|description|
-------------------
|  1  |price: 43  |
|     |name1      |
|     |name2      |
|     |           |
-------------------
|  2  |price: 52  |
|     |           |
|     |name3      |
|     |name4      |
-------------------

This is a gross simplification of the table I have, which has much more rows and much more empty lines. Would anybody know how to address this issue?

1 Answers

Depending on the output format, an empty text will still create visible vertical spacing.

I see three options:

1) You could use a parameter in your detail dataset to select only the items belonging to the current order from the order dataset.

2) You can use just one data set and use a group in the layout table/list.

3) You can keep your data sets and use a visibility expression. If you are using a table item for the items, you should add this visibility expression to the detail row, not to the dynamic text item. The visibility expression would be row["order_no"] != row._outer["order_no"]

Related