Enabling user filtering after data retrieval
This option is available for all data sources, including JDBC, XML, and text file, but filtering at query run time using data set parameters is the preferred approach for JDBC for performance reasons.
Though the goal in enabling users to filter at query run time and after BIRT retrieves the data is the same, the steps are different. To enable users to filter after data retrieval, complete the following tasks in the recommended order. For detailed information about these tasks, see the corresponding topics later in this section.
*Create report parameters to prompt a user to specify field values that determine what data to display.
*Create one filter condition for each field for which you want the user to supply a value. Set the value of each filter condition to a report parameter to dynamically update the filter condition with the parameter value.
*Determine how to present the report parameters.
*Test the report parameters.
Creating a report parameter
The procedure for creating a report parameter is the same whether enabling user filtering at query run time or after data retrieval. Follow the steps described earlier in this section.
Providing a filter condition value when the report runs
Typically, when you specify a filter condition to display only certain data in a report, you specify the value on which to search, as in these examples:
row["quantityinstock"] Less than 500
row["productvendor"] Equal to "Exoto Designs"
To enable a user to filter data when the report runs, specify the report parameter value as the filter value. The following expressions are examples of filter conditions for which values are set to report parameter values:
row["quantityinstock"] Less than params["RP_quantityinstock"].value
row["productvendor"] Equal to params["RP_productvendor"].value
When the user runs the report and supplies a value for the report parameter, BIRT dynamically updates the filter condition with the parameter value and generates a report that displays only the specified data.
How to provide a filter condition value when the report runs
This procedure assumes that you already created a report design that contains a table or list to display data from a data set and uses one or more report parameters. This procedure uses the parameter to filter the values that the table displays.
1 In the layout editor, select the table element or list element to filter.
2 In Property Editor, choose the Filters tab.
3 Choose Add to create a new filter condition.
4 In New Filter Condition, specify the filter condition.
1 In the first field, select a field from the drop-down list. Alternatively, open the expression builder to create a more complex expression.
2 In the second field, select an operator from the drop-down list.
3 In the third field, specify the name of the report parameter that you created. You can use the expression builder to select the report parameter from the list of report parameters in the report design, as shown in Figure 13‑8.
Figure 11-5 Using the expression builder to select a report parameterFigure 11-5 Using the expression builder to select a report parameter
Figure 13‑8 Using the expression builder to select a report parameter
Choose OK to apply the expression to the filter condition. New Filter Condition displays the completed filter condition, as shown in Figure 13‑9.
Figure 11-6 A filter conditionFigure 11-6 A filter condition
Figure 13‑9 A filter condition
5 Choose OK to save the filter condition.
The filter condition appears on the Filters page in Property Editor, as shown in Figure 13‑10.
Figure 11-7 Filter condition set to a report parameterFigure 11-7 Filter condition set to a report parameter
Figure 13‑10 Filter condition set to a report parameter
6 Preview the report.
Enter Parameters appears and displays the report parameters that you created. Figure 13‑11 shows an example.
Figure 11-8 Enter Parameters showing a report parameterFigure 11-8 Enter Parameters showing a report parameter
Figure 13‑11 Enter Parameters showing a report parameter
7 Specify values for the report parameters, then choose OK.
The report displays data that matches the values that you specified.