Previous Next

Task 6:  Sort the data

When you first create and preview a report, the report displays the data rows in the order in which the query returns them. The order can vary, depending on many factors, such as how data was supplied in the data source. In most cases, you will want to change the order in which data appears in the report.

In the layout editor, select the table by selecting the Table tab in the lower left corner, as shown in Figure 1-18. This tab appears when you hover the mouse pointer over the lower left corner of the table.

Figure 1-18 Selecting the table

Figure 1-18  Selecting the table
Property Editor displays the properties for the table, as shown in Figure 1-19.

Figure 1-19 Property Editor displaying the general properties of the table

Figure 1-19  Property Editor displaying the general properties of the table
Figure 1-20 shows the sort definition.

Figure 1-20 Sort definition in New Sort Key

Figure 1-20  Sort definition in New Sort Key
Choose OK. The Sort page displays the defined sort key.

Figure 1-21 Data sorted by customer name

Figure 1-21  Data sorted by customer name
Notice that names with uppercase letters appear at the top of the list. BIRT sorts string data by UCS-2 code point values. In ASCII-based character sets, uppercase letters have lower code point values than lowercase letters. Therefore, uppercase letters appear before lowercase letters.
In the Sort page, shown in Figure 1-22, select the sort key, then choose Edit.

Figure 1-22 Sort key displayed on the Sort page

Figure 1-22  Sort key displayed on the Sort page
This expression uses the JavaScript toUpperCase( ) function to convert all the customer name values to uppercase before sorting. JavaScript function names are case-sensitive, so you must type toUpperCase( ) exactly as shown. References to column names are also case-sensitive. In this expression, row["CUSTOMERNAME"] is the correct name to use. If you type row["customername"], for example, BIRT Report Designer displays an error when you run the report. You can verify the capitalization of a column name by looking at the name that is displayed in Data Explorer.

(c) Copyright Actuate Corporation 2013