Sorting report data
You can sort the records in a banded object or table, and the groups in a certain group level of the banded object or table if you have defined one or more group levels. If you want the data of other types of cube elements to be sorted, you should put the cube element into a banded object or table and make the data of the cube element inherit from the banded object or table.
- Sorting records: Changing the order of records in the whole banded object or table, or in each group if there exists one or more group levels. The sorting scope is the whole banded object or table.
- Sorting groups at a group level: Changing the order of groups at the specified group level, that is, the groups will be sorted by value of the first record in each group on the related field. The sorting scope is the group level.
You can achieve the above by using the Sort dialog, shortcut menu, or labels.
Using the Sort dialog
To set the sort conditions in the Sort dialog:
- Click Menu > Report > Sort, or the Sort button on the Analysis toolbar. The Sort dialog appears.
See the dialog.
- From the Sort in Scope drop-down list, select a banded object/table or a group field on which the sort condition will be based.
- From the field drop-down list, select the field on which to sort the data, then set the sort order to Ascend or Descend.
- If you select a banded object/table in Step 2, you can click to add a new row of sorting condition if required. Click or to move a row up or down so as to set the sorting priority, to delete the corresponding sorting condition if it is unwanted.
If what you select in the Sort in Scope drop-down list is a group field, then only one sort condition can be composed.
To retrieve the opening status of this dialog, click the Reset button.
- Click OK to accept the settings and to reload the result.
Using the shortcut menu
To sort data on a certain field using shortcut menu:
- Point to any value of a detail field or group field by which to sort the data in the banded object/table, and then right-click.
- Choose the command Sort > Ascend or Sort > Descend from the shortcut menu.
If what you right-click in Step 1 is a detail field value, the sorting will affect the order of detail records in the banded object or table; if it is a group field value, the order of groups in the group level represented by the group field will be rearranged.
To remove the sort condition on a field, click Sort > No Sort.
Using labels
You can use a label to control the sorting order for a certain field. This feature needs to be enabled at report design time.
- In JReport Designer, select a label in a banded object/table, and then set the Sortable property of the label to true.
- Set the field by which you want to sort records as the value of the label's Bind Column property.
- Save the report and publish it to JReport Server.
- Run the report in Page Report Studio, and you can click beside the label to sort the data. This button will change after you have clicked it, and you can further click it to switch the sorting direction among ascend, descend, and no sort.
Notes:
- You cannot sort the data by a global type formula.
- You can also conduct sorting by using the shortcut menu for a label in the same way as for a field value, provided you have set its Bind Column property.
- For sorting the data using shortcut menu or labels, you may notice that the corresponding sort expressions will appear in the Sort dialog if you open this dialog.
- If you use the shortcut menu to sort the report data by a field and then sort by another field, the later sort condition will replace the former one.
- JReport allows you to define display names for fields to be showed in the Sort dialog. For detailed information, see Customizing the field display names in the JReport Designer User's Guide.
- You can right-click an object in a banded object and select the Reset item from the shortcut menu to reproduce the data of the banded object using the data cached in the data buffer. This will clear all sort and filter conditions except for those predefined in JReport Designer.
- Administrators can customize the buffer size for sorting of each report in the Configuration page of JReport Server so as to improve performance.