
Filtering report data
In JReport Web, data is cached in a data buffer. You can set a series of conditions and apply them to a DHTML server to filter the data buffer and reproduce the report result.
There are three methods you can use to set the filter conditions: using the Filter dialog, using the shortcut menu, and using labels. However, when you are to filter a crosstab or chart, you can only use the Filter dialog. The other two methods do not apply to crosstabs and charts.
Using the Filter dialog
To set the filtering conditions using the Filter dialog:
- Click Menu > Report > Filter (or the Filter button
on the Analysis toolbar) to show the Filter dialog. See the dialog.
- Select the component on which the filtering will be based from the Apply to drop-down list.
- Click the Add Condition button to add a filter line.
- From the field drop-down list, select the field on which the filter will be based.
- From the operator drop-down list, set the operator with which to compose the filter expression.
- Type the value(s) of how to filter the field into the value text box, or click the button
to specify one or more values in the Select Values dialog (for details about how to define values in the dialog, refer to Select Values dialog).
- To add another line of filter expression, click the Add Condition button and define the expression as required, then from the logic drop-down list, specify the relationship between the two filter expressions.
- Repeat the above steps to add more filter expressions if necessary.
To make some conditions grouped, select them and click the Group button, then the selected conditions will be added in one group and work as one line of filter expression. To make any condition in a group out, select it and click Ungroup.
To adjust the priority of the conditions, select it and click the Up or Down button.
To delete a condition you have already added, select the condition and click the Delete button.
To retrieve the opening status of this dialog, click Reset.
- Click OK to make the filter take effect and return to the report.
Using the shortcut menu
You can also use filter-related commands on the shortcut menu to filter the data in a banded object or table. To do this, point to any value of the field by which you want to filter data, then right-click to show the shortcut menu. You will see the Filter item which provides a submenu containing the following commands:
- Remove Filter
This command is enabled after you have applied filtering on the field to the banded object or table. Clicking this item will remove all filters on this field.
- Top N
Shows the Top N dialog with which you can filter data to display records that meet the Top N condition.
For example, if you input 3 in the Top N dialog for a certain field, then only the records with the field value equal to one of the first three field values will be displayed.
- Bottom N
Shows the Bottom N dialog with which you can filter data to display records that meet the Bottom N condition.
For example, if you input 3 in the Bottom N dialog for a certain field, then only the records with the field value equal to one of the last three field values will be displayed.
- Field values
"Field values" is not the name for a command on the Filter submenu, but represents some items which are the values of the field you have right-clicked. Selecting any field value listed here will make the banded object or table only display records with the field value equal to the selected one.
- More
This command is enabled if the Filter submenu cannot list all field values. When it is enabled, clicking it will show the Select Values dialog. You can select one value in this dialog and apply the setting, after which the banded object or table will only display records with the field value equal to that value.
Using labels
You can also use a label to control the filter condition in a banded object or table. This feature needs to be enabled at report design time.
- In JReport Designer, select a label in a banded object/table, and then set its Filterable property to true.
- Set the field by which you want to filter records as the value of the label's Bind Column property.
- Save the report set and publish it to JReport Enterprise Server.
- Run the report set in JReport Web, and you can find that a button
is beside the label. Click it to show the Filter list, which contains All, Top N, Bottom N, Custom Filter, the field values, and More (if there are too many distinct values for the field), then click the corresponding item to filter the records.
After applying a filter on the field decided by the Bind Column property, the button
will be affixed with a check mark, and you can still click it to show the Filter list, in which the All item can help you remove the filters on the field.
Notes:
- You can also filter records 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 value to a field.
- When using the shortcut menu for a field value or label to filter, all the items (Remove Filter, Top N, Bottom N, and More) will be showed by default. If you want to disable some of the items, you should set the field's Filter Options property when designing the report set in JReport Designer. For details, see Setting filter options for a field in the JReport Designer User's Guide.
- For filtering the data using shortcut menu or labels, you may notice that the corresponding filter expressions will appear in the Filter dialog if you open this dialog.
- JReport allows you to define the display names for fields to be shown in the Filter dialog. For detailed information, see Customizing the field display names in the JReport Designer User's Guide.
