In the example Employee Listing report from Chapter 3, The BIRT Environment and First Report, we used a visual report element called a Table, even if we didn't know it. The Table is similar to the Grid component we saw in the previous chapter, except that it is data bound. What this means is that the contents of this component are populated by data stored in a data container such as a dataset. In the Employee Listing report, we saw a shortcut method for creating a table. This is very useful when we are building simple listing reports. However, when we need more precise control over our Table, we can also do it manually using the Palette component.
The Table is divided into three logical groups:
In the following example, we are going to demonstrate two different ways to create tables. First we will build tables using the shortcut drag-and-drop dataset method. Then we will use the second method, which involves manually building a table, binding it to a dataset, and populating the elements of the table.
First we want to get the data from dsetJoined
and move it over to our Layout view. There are a couple of different ways this can be accomplished. We can drag it over from the Data Explorer just like we did in Chapter 3 or we can drag it over from the Outline view. If we right-click on the dsetOrders
, we can also choose the Insert into Layout option. The caveat with this is that if there is already any element in the layout, we will have to click on an empty space in the Layout editor for this option to be available.
dsetJoined
and choose Insert in Layout. tblEmployeePayments
. dsetFlatFilePayments: firstName
and dsetFlatFilePayments
. Click on the grey square above these labels to select that entire column. Then right-click, and choose Delete. Repeat this for both columns. dsetXMLEmployee::
or dsetFlatFilePayments
. To do this, we can either double-click on each of them or can use the Property Editor. To use the Property Editor, select the label element either in the Layout Editor or, using the Outline, select the label under each of the Body, Table, Header, Row, Cell, Label components. Then in the Property Editor, scroll down to Advanced and select Content. Change each label to an appropriate title.agrPaymentTotal
Float
SUM
agrPaymentTotal
component and format it as Currency.
So, creating a simple report this way is easy enough, but how would we do so manually. Well, that's exactly what we are going to do next.
We want to create a table right below this one with the information from the dsetOrders
. We will create this one manually as we do not want to display all the information in that dataset, but only certain columns. Because we should be fairly familiar with using the Component palette at this point, we are going to create this table directly in the Layout Editor.
tblEmployeePayments
, and choose Insert | Table. dsOrders
as the dataset.cbOrderNumber
Integer
row["ORDERNUMBER"]
Here, we manually created a data element in the detail row. Note the expression. This expression is telling BIRT to use the value or ORDERNUMBER in the current row, as the detail band in a table will cycle through every record returned in a dataset.
dsetOrders
node. Drag over the CUSTOMERNUMBER
field to the detail rows second column. We can see the header label is automatically created. PRODUCTCODE, PRICEEACH
, and QUANTITYORDERED
field.Float
row["PRICEEACH"] * row["QUANTITYORDERED"]
Product Total
detail cell and the PRICEEACH
cell as Currency
.