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.

1  
2  
Open Property Editor, if necessary. If you use the default report design perspective, Property Editor appears below the layout editor. If it is not open, choose WindowShow ViewProperty Editor.
3  
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
Property Editor displays the properties for the table, as shown in Figure 1-19.

Figure 1-19 Property Editor

Figure 1-19  Property Editor displaying the general properties of the table
4  
5  
n  
n  
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.
6  

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.
7  
Sort the customer names case-insensitively so that ANG Resellers appears after American Souvenirs Inc., rather than before.
1  
2  
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
3  
row["CUSTOMERNAME"].toUpperCase()
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.
8  

(c) Copyright Actuate Corporation 2011